alloc / alloc/saus

Make state modules more ergonomic

Open
#52 1 comment 0 reactions 0 assignees View on GitHub
proposal roadmap
Dominant language
TypeScript
Stars
38
Forks
1
PR merge metrics
No merged PRs in 30d

Description

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)
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.