Effect CommunityEC
Effect Community3y ago
23 replies
imagio

Preferred Patterns for Providing Access to State

What's the preferred pattern for providing access to state? I see a few possibilities but am not sure which one ends up being most easy/clean/maintainable/readable

1. Pass Refs into a function that returns an effect
2. Capture Refs in a closure
3. Provide Refs via Context
4. Refs as fields on a Class
5. Create Refs top level in a file (assuming you only need a single instance for the life of the program)

Which do you prefer and why?
Was this page helpful?