urgent/thisbounty.com-events

App Persistence

urgent opened this issue · 2 comments

Websocket and local storage self-contained in components.

  • Test websocket in a component
  • Test local storage in a component

Don't emit events in effects.

  • Protect against race conditions

  • Test across components.

  • Performance for events which chain renders

  • Multiple components listening on the same event.

  • Efficient render for events

Consider

  • Bounty hurt, render
  • Bounty emits critical health event
  • Moneybar hurt, render
  • Health heal, render
  • Moneybar heal from websocket autopay

3 renders to be back in same state. Shared props would have caught this and just not rendered. Catching events depends upon state.

When building an auto-heal feature, refactor healthbar and moneybar to share props, thinking in react. Both have atomic events for components, and efficient render.

Also might be nice to render, show all those animations then just nothing.

Avoid Pre-optimization

#3.16

Good to keep in mind and document, but move fast. Don't be afraid to reject the issue. Save for real feature.

In this case, concerns about event emitter. Emit an event, which emits an event itself. Fix by removing the concept entirely. Don't emit events in effects. If another component needs to respond, subscribe to the original event. For instance moneybar responds to health by keeping it's own score. If complicated, lift state up.