That's interesting. Scares me a bit. Part of me really wants to make mutation(assignment) special and isolated but I just might not be letting go enough to fully embrace this thinking. Would it ever be difficult to reverse the derivations? Sure subtracting 1 from b is easy enough. I just wonder if that wouldn't always be the case.
No, It's very common. We can bind local property with part of json which bind with local storage as example. So write to property will change json at local storage and affects to same property of another instance of same app. Example:
let _a = 10
const a = ( next = 10 )=> return _a = next
const b = ( next )=> a( next === undefined ? undefined : next - 1 ) + 1
a(20);
Assert.AreEqual(21, b());
b(20);
Assert.AreEqual(19, a());
We actively use this that approach in this way:
class App {
// it's signal
@ $mol_mem
static a( next = 10 ) { return next }
// it's derivation but with same api as signal
@ $mol_mem
static b( next ) {
return this.a( next === undefined ? undefined : next - 1 ) + 1
}
}
App.a(20);
Assert.AreEqual(21, App.b());
App.b(20);
Assert.AreEqual(19, App.a());
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
That's interesting. Scares me a bit. Part of me really wants to make mutation(assignment) special and isolated but I just might not be letting go enough to fully embrace this thinking. Would it ever be difficult to reverse the derivations? Sure subtracting 1 from b is easy enough. I just wonder if that wouldn't always be the case.
It only makes sense if the mapping is a bijection (math term). It's a really rare property, meaning zero information loss.
No, It's very common. We can bind local property with part of json which bind with local storage as example. So write to property will change json at local storage and affects to same property of another instance of same app. Example:
Bi-directional bindings re-invented? Fair enough.
It's the lens in general. See JS example:
We actively use this that approach in this way: