-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui: Small EventSource additions (#5978)
1. EventSources now pass themselves thorugh to the run function as a second argument. This enables the use of arrow functions along with the EventSources API `(configuration, source) => source.close()`. Order of arguments could potentially be switched at a later date. 2. BlockingEventSources now let you pass an 'event' through at instantation time. If you do this, the event will immediately be dispatched once the EventSource is opened. The usecase for this is for 'unfreezing' cached BlockingEvents. This makes it easier to provide a cache for BlockingEventSources by caching its data rather than the entire BlockingEventSource itself. ``` new BlockingEventSource( (config, source) => { /* something */ }, { cursor: 1024, // this would also come from a cache currentEvent: getFromSomeSortOfCache(eventSourceId) //this is the new bit } ); // more realistically new BlockingEventSource( (config, source) => { return data.findSomething(slug, config) }, getFromSomeSortOfCache(eventSourceId) ); ```
- Loading branch information
Showing
2 changed files
with
21 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters