Skip to content

Commit

Permalink
Add AwaiEvent example to about page
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriyyakym committed Dec 22, 2023
1 parent c3fa6f6 commit 05640e5
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions docs/docs/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,21 @@ Awai helps with organizing asynchronous logics and handling race conditions with
npm install awai
```

### Integrations
### How AwaiEvent works

- **React** - [GitHub](https://github.com/yuriyyakym/awai-react), [NPM](https://www.npmjs.com/package/awai-react)
You are not likely to use it directly, the code is just for demonstration purposes.

```ts
const event = new AwaiEvent();

setTimeout(event.emit, 100, 'hello');
setTimeout(event.emit, 200, 'awai');

const value1 = await event;
const value2 = await event;

console.log(`${value1} ${value2}`); // hello awai
```

### Basic example

Expand All @@ -59,7 +71,7 @@ import TabItem from '@theme/TabItem';

<TabItem value="js" label="JavaScript">

```ts title="Todo list state management"
```js title="Todo list state management"
import { action, state } from 'awai';
import { getUniqueId } from './utils';

Expand Down Expand Up @@ -124,6 +136,10 @@ export const toggleTaskIsCompleted = action((id: Task['id']) => {

</Tabs>

### Integrations

- **React** - [GitHub](https://github.com/yuriyyakym/awai-react), [NPM](https://www.npmjs.com/package/awai-react)

### Name meaning

The name comes from a Thai phrase [เอาไว้](https://www.thai2english.com/dictionary/1457374.html) which means "to keep/save/store for later".

0 comments on commit 05640e5

Please sign in to comment.