alloc / alloc/saus

Make state modules more ergonomic

未关闭
#52 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
proposal roadmap
主要语言
TypeScript
星标
38
派生
1
PR 合并指标
30 天内没有已合并 PR

描述

Currently, state modules typically look like normal variables (lowercased), and you use their `.get` or `.load` methods as appropriate. When unwrapping a state module into its raw value, it can be awkward to decide on what the unwrapped value's variable will be named. This proposal is a possible solution.

```ts
import { defineStateModule } from 'saus/client'

export const [getFoo, loadFoo] = defineStateModule(
'foo',
async function() {
// TODO: Load the foo
}
)
```

With this pattern, the awkwardness is avoided:

```ts
import { getFoo, loadFoo } from '../state/foo'

let foo = getFoo(1, 2, 3)

foo = await loadFoo(3, 4, 5)
```

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。