@solana/subscribable
Advanced tools
Comparing version 2.0.0-canary-20241004212313 to 2.0.0-canary-20241004212851
export * from './async-iterable'; | ||
export * from './data-publisher'; | ||
export * from './demultiplex'; | ||
export * from './event-emitter'; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@solana/subscribable", | ||
"version": "2.0.0-canary-20241004212313", | ||
"version": "2.0.0-canary-20241004212851", | ||
"description": "Helpers for creating subscription-based event emitters", | ||
@@ -60,3 +60,3 @@ "exports": { | ||
"dependencies": { | ||
"@solana/errors": "2.0.0-canary-20241004212313" | ||
"@solana/errors": "2.0.0-canary-20241004212851" | ||
}, | ||
@@ -63,0 +63,0 @@ "peerDependencies": { |
@@ -87,2 +87,27 @@ [![npm][npm-image]][npm-url] | ||
### `demultiplexDataPublisher(publisher, sourceChannelName, messageTransformer)` | ||
Given a channel that carries messages for multiple subscribers on a single channel name, this function returns a new `DataPublisher` that splits them into multiple channel names. | ||
Imagine a channel that carries multiple notifications whose destination is contained within the message itself. | ||
```ts | ||
const demuxedDataPublisher = demultiplexDataPublisher(channel, 'message', message => { | ||
const destinationChannelName = `notification-for:${message.subscriberId}`; | ||
return [destinationChannelName, message]; | ||
}); | ||
``` | ||
Now you can subscribe to _only_ the messages you are interested in, without having to subscribe to the entire `'message'` channel and filter out the messages that are not for you. | ||
```ts | ||
demuxedDataPublisher.on( | ||
'notification-for:123', | ||
message => { | ||
console.log('Got a message for subscriber 123', message); | ||
}, | ||
{ signal: AbortSignal.timeout(5_000) }, | ||
); | ||
``` | ||
### `getDataPublisherFromEventEmitter(emitter)` | ||
@@ -89,0 +114,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
126935
23
991
125
+ Added@solana/errors@2.0.0-canary-20241004212851(transitive)
- Removed@solana/errors@2.0.0-canary-20241004212313(transitive)