avkonst / hookstate

The simple but very powerful and incredibly fast state management for React that is based on hooks
https://hookstate.js.org
MIT License
1.64k stars 106 forks source link

What is the meaning of `E` in State<S, E>? #390

Open onhernandes opened 1 year ago

onhernandes commented 1 year ago

I've been trying to implement an extension like localstored, but with a better approach for onSet + using react-native-async-storage. On every plugin in this repo there's a declaration of State<S, E>. As far as I know, S stands for the type of the value itself, but what about E? What does it mean? How should I use it?

obs> My extension won't be needing other extensions.

avkonst commented 1 year ago

E is a final merge of extension methods and props from all extensions added to the state. Most of the time it is inferred automatically from the attached extension. Your extension might have E as only {} if you do not need extension methods. Also have a look at the existing localstored, it allows to pass storage engine, which I believe is async capable. If you have any questions regarding development of the extension feel free to ask. If you feel your extension is generic enough, you may include it to the hookstate repo