ds300 / derivablejs

Functional Reactive State for JavaScript and TypeScript
Apache License 2.0
515 stars 23 forks source link

Added value property to Atom. #77

Closed PFight closed 6 years ago

PFight commented 6 years ago

I license my contributions to the DerivableJS project under the Apache License 2.0.

TrySound commented 6 years ago

There is a section in readme

Key differences with MobX

It is always necessary to call .get on derivables to find out what's inside, and you always have to call .set on atoms to change what's inside. This provides a consistent semantic and visual distinction between ordinary values and derivable values.

PFight commented 6 years ago

I understand, but I think, .value is not so transparent. It is explicit enough to distinguish atom from ordinary value. Just more convinient syntax:

$atom.set($atom.get() + 1) $atom.value = $atom.value + 1; // Much nicier

TrySound commented 6 years ago

I wouldn't said it's much nicer since you are introduce some implicit magic via setter and getter. Also there is already an API for that. Introducing another one adds inconsistency in a team and as a result complexity. API should have only one way to do one thing.