-
Notifications
You must be signed in to change notification settings - Fork 54
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
Durable Objects syntax idea #86
Comments
Renaming const app = new HonoObject(async (c) => {
c.state.value = await c.storage.get<number>('value') || 0
})
app.get('/increment', async (c) => {
const newVal = c.state.value++
c.storage.put('value', newVal)
return c.text(newVal.toString())
})
app.get('/decrement', async (c) => {
const newVal = c.state.value--
c.storage.put('value', newVal)
return c.text(newVal.toString())
})
app.get('/', async c => {
return c.text(c.state.value.toString())
})
export { app as Counter } |
Oooh, I like this. I have some thoughts, but will move discussion to sor4chi/hono-do#1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looking at https://github.com/honojs/examples/blob/main/durable-objects/src/counter.ts, I wanted to try something that makes a Durable Object feel more like a stateless application but with a
c.state
property. So I came up with this:The text was updated successfully, but these errors were encountered: