From 05640e52486c92ff96f6e1e6031da97aecb7d735 Mon Sep 17 00:00:00 2001 From: Yuriy Yakym Date: Sat, 23 Dec 2023 01:08:54 +0700 Subject: [PATCH] Add AwaiEvent example to about page --- docs/docs/about.md | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/docs/docs/about.md b/docs/docs/about.md index 2895b93..f903615 100644 --- a/docs/docs/about.md +++ b/docs/docs/about.md @@ -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 @@ -59,7 +71,7 @@ import TabItem from '@theme/TabItem'; -```ts title="Todo list state management" +```js title="Todo list state management" import { action, state } from 'awai'; import { getUniqueId } from './utils'; @@ -124,6 +136,10 @@ export const toggleTaskIsCompleted = action((id: Task['id']) => { +### 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".