Implementation of createEverithingMutableWithMagic() and make everything reactive by magic. #1336
awillSoftwares
started this conversation in
Ideas
Replies: 1 comment
-
This was achived by using MobX with SolidJS. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
There are cases when we need all the object and nested objects/arrays reactive.
The way we need to change nested objects/arrays in SolidJS is too much opinative from the framework.
In order to make existent codebases portable to SolidJs and to use patterns Object Oriented / Clean Architecture / Design Driven Design, would be incredible awesome if we had something like createEverithingMutableWithMagic()
In Svelte we can use classes (with nested objects/arrays) and when we reassign an class instance, like: users = users; All the nested objects will be reactive.
Same in svelte stores with $store when object has changed;
If we create javascript classes with
Everything becomes reactive by default. If is there a way to create an object like
let someService = createEverithingMutableWithMagic(new Service())
and make all the nested objects reactive by default, maybe using $PROXIABLE symbols.
Here is some example how to make everything reactive by default using return createMutable(this) in constructor:
EDITED: In my example all the things will work event without the createMutable(this) in constructor. But if we have some nested objects and arrays using class, only the first update will work and only for the first element of Array. I will update with some examples to show the use cases for this.
(When we have some store that use class with nested
<For>
loops, the nested objects doesnt become reactive) and the way SolidJS work to change nested objects is too much opinated)https://playground.solidjs.com/?version=1.4.1#NobwRAdghgtgpmAXGGUCWEwBowBcCeADgsrgM4Ae2YZA9gK4BOAxiWGjIbY7gAQi9GcCABM4jXgF9eAM0a0YvADo1aAGzQiAtACsyAegDucAEYqA3EohWOXHrwLF+AYQVcIw3NLkLeAcjoNbT0-Swhbbj4QZiEoXDgAWXpcKBM1OG95RRVAzV0DMlxuOAsbTkj+ADFuTN8c9Ty9UusPCHpFVwgPZlw0WggAZRTcejJ+K15J3gB5CA0PXgBeZTBpgDkAGQBJNYBRFSwJqemZGXm4JZWTs4wSsCtJKytmNSgyMYBVMnFxiCneQj0NJoZi8TSIXiFRgYADmYX+gOBoOg8AhUNh8KmiI0oMKcVGEM63V6-SG+LIYSOk2Y-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