Skip to content

Commit

Permalink
Release 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
majo44 committed Nov 13, 2020
1 parent 1f4d1a4 commit 815ed49
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log
This project adheres to [Semantic Versioning](http://semver.org/).

## 1.0.2
* Readme update.

## 1.0.1
* Readme update.

Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,29 @@ store.on('documentLoaded', (_, {id, document}) => ({
}));

// awaiting for the ending event

const documentLoadedPromise = await until(store, 'documentLoaded', (_, {id}) => id === 'id1');
// dispatch event
store.dispatch('loadDocument', 'id1');
// waits until async flow will finish
const {id, document} =
await until(store, 'documentLoaded', (_, {id}) => id === 'id1');
const {id, document} = await documentLoadedPromise;

console.log(document);

// we can also await for the state

const statePromise = until(store, '@changed', ({id}) => id === 'id2');
// dispatch event
store.dispatch('loadDocument', 'id2');
// waits until data in state will pass condition
const {id, document} =
await until(store, '@changed', ({id}) => id === 'id2');
const {id, document} = await statePromise;
console.log(document);

```

**Caution**

Please notice, that we should always use `until` utility to create promise before the event dispatch
as dispatched event can run synchronously.

### Api
- `until` - is function which returns promise of requested event data. Params:
- `store` the store
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "storeon-until",
"version": "1.0.1",
"version": "1.0.2",
"description": "Small simple utility for awaiting [Storeon] event occurs",
"repository": {
"type": "git",
Expand Down

0 comments on commit 815ed49

Please sign in to comment.