Skip to content
This repository has been archived by the owner on Jul 21, 2021. It is now read-only.

Commit

Permalink
- Updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
novacbn committed May 19, 2020
1 parent a1dac17 commit f9c4673
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/stores/browser/query_param.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function QueryParamOptions(options: Partial<IQueryParamOptions> = {}): IQueryPar
/**
* Returns a `Writable` Svelte Store, which binds to a specific query string parameter
*
* ```javascript
* ```html
* <script context="module">
* const SORTING_MODES = {
* ascending: "ASCENDING",
Expand Down
24 changes: 24 additions & 0 deletions src/util/shared/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,30 @@ export interface IEvent<T> {

/**
* Returns a new [[IEvent]] instance, for handling event publishing in non-DOM related contexts
*
* As a minimal example:
*
* ```javascript
* import {event} from "svelte-commons/lib/util/event";
*
* // Initialize our event publisher as a singleton
* const MY_EVENT = event((dispatch) => {
* // The callback we provided, will run whenever we get a first subscriber
* console.log("Got my first subscriber!");
*
* return () => {
* // And the callback returned, will run whenever we lose our last subscriber
* console.log("Lost my last subscriber!");
* };
* });
*
* MY_EVENT.subscribe((details) => {
* console.log(details);
* }); // Will log any dispatches to the event publisher
*
* MY_EVENT.dispatch({message: "Hello world!"}); // logs: `{"message": "Hello world!"}`
* ```
*
* @param start
*/
export function event<T>(start: IEventNotifier<T>): IEvent<T> {
Expand Down

0 comments on commit f9c4673

Please sign in to comment.