@foundit/broadcasterjs
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -171,6 +171,6 @@ "use strict"; | ||
START SUBSCRIPTION VANILLA JS | ||
broacaster.on(['BROADCAST-ID', ({ detail }) => { | ||
broacast.on(['BROADCAST-ID', ({ detail }) => { | ||
document.body.append(detail + ' '); | ||
}]); | ||
broacaster.once(['BROADCAST-ID', ({ detail }) => { | ||
broacast.once(['BROADCAST-ID', ({ detail }) => { | ||
document.body.append(detail + ' '); | ||
@@ -180,3 +180,3 @@ }]); | ||
END SUBSCRIPTION | ||
broacaster.off(['BROADCAST-ID', ({ detail }) => { | ||
broacast.off(['BROADCAST-ID', ({ detail }) => { | ||
document.body.append(detail + ' '); | ||
@@ -183,0 +183,0 @@ }]); |
20
index.ts
@@ -41,2 +41,7 @@ export type ListenerProps = <T extends unknown>([type, listener, settings]: [ | ||
const { exists, id } = handleCache().listenerExists(type, listener, options) | ||
if (exists) | ||
console.log({ | ||
string: `Subscriber existed ${type}`, | ||
obj: broadcastItemsCache, | ||
}) | ||
if (exists && !options.allowDoublettesSubscribers) return id | ||
@@ -154,3 +159,10 @@ if (options.debug) | ||
const remove = (type: string, listener: unknown) => { | ||
const removeId = createBroadcastId(type, listener) | ||
const removeId = type + createBroadcastId(type, listener) | ||
debugmode({ | ||
string: `Remove listener: ${removeId}`, | ||
obj: | ||
broadcastItemsCache.indexOf(removeId) !== -1 | ||
? 'Existed' | ||
: `Didn't exist`, | ||
}) | ||
broadcastItemsCache = broadcastItemsCache.filter((id) => id !== removeId) | ||
@@ -222,6 +234,6 @@ } | ||
START SUBSCRIPTION VANILLA JS | ||
broacaster.on(['BROADCAST-ID', ({ detail }) => { | ||
broacast.on(['BROADCAST-ID', ({ detail }) => { | ||
document.body.append(detail + ' '); | ||
}]); | ||
broacaster.once(['BROADCAST-ID', ({ detail }) => { | ||
broacast.once(['BROADCAST-ID', ({ detail }) => { | ||
document.body.append(detail + ' '); | ||
@@ -231,3 +243,3 @@ }]); | ||
END SUBSCRIPTION | ||
broacaster.off(['BROADCAST-ID', ({ detail }) => { | ||
broacast.off(['BROADCAST-ID', ({ detail }) => { | ||
document.body.append(detail + ' '); | ||
@@ -234,0 +246,0 @@ }]); |
{ | ||
"name": "@foundit/broadcasterjs", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A simple yet powerful pub/sub javascript event bus", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -11,3 +11,4 @@ # broadcasterjs | ||
[Demo app available](https:broadcasterjs.hervy.se) | ||
[Demo app available](http://broadcasterjs.hervy.se) | ||
[Demo app source code](https://github.com/nicatspark/broadcasterjs-demo-app) | ||
@@ -24,3 +25,3 @@ --- | ||
useEffect(() => { | ||
broadcast.on(['BROADCAST-ID', flagReceivedFunction]) | ||
broadcast.on(['MYBROADCAST-ID', flagReceivedFunction]) | ||
}, [flagReceivedFunction]) | ||
@@ -32,4 +33,4 @@ ``` | ||
```typescript | ||
broacaster.on([ | ||
'BROADCAST-ID', | ||
broacast.on([ | ||
'MYBROADCAST-ID', | ||
({ detail }) => { | ||
@@ -42,4 +43,4 @@ document.body.append(detail + ' ') | ||
```typescript | ||
broacaster.once([ | ||
'BROADCAST-ID', | ||
broacast.once([ | ||
'MYBROADCAST-ID', | ||
({ detail }) => { | ||
@@ -54,4 +55,4 @@ document.body.append(detail + ' ') | ||
```typescript | ||
broacaster.off([ | ||
'BROADCAST-ID', | ||
broacast.off([ | ||
'MYBROADCAST-ID', | ||
({ detail }) => { | ||
@@ -66,3 +67,3 @@ document.body.append(detail + ' ') | ||
```typescript | ||
broadcast.emit('BROADCAST-ID', 'Hello world') | ||
broadcast.emit('MYBROADCAST-ID', 'Hello world') | ||
``` | ||
@@ -69,0 +70,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30013
531
88