Skip to content
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

What are the rules for reactive? Can I use es2015 classes in my "state" #94

Open
logankaser opened this issue Nov 10, 2023 · 4 comments

Comments

@logankaser
Copy link

What the title says, generally would be nice to know more about how it works
so that I can tell how it's intended to be used and what it's limitations are.
For example does data need to be "serializable" to json? Can I use Date objects or
do I need to use a string repr for those?

@justin-schroeder
Copy link
Owner

It does not technically need to be serializable, but it does need to be easy to proxy and generally not use any methods for access. Maps/Sets, for example do not work because they would require that we extend the proxy surface area to all their methods. If you had a custom class that used simple property access myInstance.foo = 123 and myInstance.foo then it should work fine. POJOs are the "safest" bet at the moment.

Of course arrow is experimental, so we could decide to make this more comprehensive, but I’d like to really stick to a tight byte budget here.

@logankaser
Copy link
Author

It might be worth a few bytes to special case Map, In my experience it that's a pretty foundational type.
I respect your byte budget goal, though. It is possible to use objects, but the ergonomics of Map really are a lot better.

Maybe it would be possible to provide a way for users to extend the proxying mechanism, so that it would
be possible for users to add support for types without needing to include that in the main library?
I think keeping the core simple is a worthy goal in and of itself though.

@irskep
Copy link

irskep commented Feb 24, 2024

+1 to the idea of letting users extend reactivity support. It seems friendly enough to let someone provide a third party "make more types work with reactivity" library.

@justin-schroeder
Copy link
Owner

I love the idea of providing a reactivity plugin mechanism. I will definitely work that into the next refactor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants