Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: define state #2

Merged
merged 22 commits into from
Sep 28, 2023
Merged

feat: define state #2

merged 22 commits into from
Sep 28, 2023

Conversation

sor4chi
Copy link
Owner

@sor4chi sor4chi commented Sep 18, 2023

This is a proposal PR to wrap storage state with react-like api.

The state is defined in such a way that storage, key, and initial value are defined, and thereafter getValue and setValue can be used in a type-safe manner.

const [getValue, setValue] = await defineState(state.storage, "value", 0);

await getValue() // 0
await setValue(1)
await getValue() // 1

await setValue((value) => value + 1) // 2
await getValue() // 2

await delValue()
await getValue() // 0

@changeset-bot
Copy link

changeset-bot bot commented Sep 26, 2023

🦋 Changeset detected

Latest commit: 510682e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
hono-do Minor
hono-do-example-batcher Patch
hono-do-example-chat Patch
hono-do-example-counter-with-state-helper Patch
hono-do-example-counter Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@sor4chi sor4chi self-assigned this Sep 27, 2023
@sor4chi sor4chi merged commit 58c529e into main Sep 28, 2023
4 checks passed
@sor4chi sor4chi deleted the feat/proposal-define-state branch September 28, 2023 23:44
@github-actions github-actions bot mentioned this pull request Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant