kwhitley / itty-durable

Cloudflare Durable Objects + Itty Router = shorter code
MIT License
236 stars 18 forks source link

Add full state to the constructor #26

Closed aarhus closed 6 months ago

aarhus commented 1 year ago

Unable to access the blockConcurrencyWhile through the proxy

kwhitley commented 1 year ago

Totally get this, but don't love the code smell if we implement it... this.state.state. Let's see if we can extend the native state, rather than appending it back into an alternative version of itself.

Example:

this.state = state // from constructor

Object.assign(this.state, {
  ...otherStuff,
})
aarhus commented 1 year ago

Just tested this and it works well - I have added a "block" function to wrap to go with the easier interfaces that you have implemented.

kschniedergers commented 10 months ago

Any progress on this? I'd love to have access to the state so I can use the websocket hibernation api

kwhitley commented 6 months ago

My bad on the delay of this... I'll get this one out ASAP