Docs in progress:
https://mweststrate.github.io/rval
STATE DESIGN
mutability granularity refs
preprocessor validation
preprocessor objects
preprocessors
- validation
- conversion
- equality checks
- models
- combing them
models
async
Tips:
- subscribe before read, or use
fireImmediately
- typing self-object referring derivations
- share methouds by pulling out /
this
/ prototype or Object.create (add tests!) - dependency injection through type generation in closure
- maps versus array entries
- comparison preprocessors
Differences with MobX:
- No 2 phase tracking, slower, but enables custom scheduling of computations
- Clear mutability / immutablility story
- No object modification, decorators, cloning
- small, with isolated tracking, fit for in-library usage
Patterns
- objects
- objects with models
- arrays
- maps
- serialization, deserialization
- capturing parent ref (see test "todostore - with parent")
- with react
- with immer (
v(p(v(), draft => { })))
) - working with references
Comparison with mobx
- factory + getter / setters -> observable. More convenient, but, pit of success
- sub(drv(x), noop) === autorun(x)
- more scheduling control; effect
Comparison with Rx
- focus on values, not events
- push / pull vs. push
- transparent tracking
Todo:
- build all the packages
- generate types
yarn tsc index.ts -t es2015 -d --outDir dist && mv dist/index.d.ts dist/rval.d.ts && rm dist/index.js &&
- test against generated packages
- setup CI
-
->sub({ scheduler, onInvalidate(f (track)))})
effect
- setup coveralls
- rval-models
- rval-react
- rval-immer
- custom schedulers
- custom preprocessors
- eliminate Reaction class
- setup minification with minified class members
- swap export statement in
tests/rval.ts
in CI to test minified build - mobx like evaluation order of drv
-
drv
with setter - combine preprocessor array
- support currying for sub:
sub(listener)(val)
- rename RvalContext to RvalInstance
- support
this.rvalProps(this.rvalProps() + 1)
->this.rvalProps(x => x + 1)
? - re-enable minification ootb
- fix sourcemaps for minified builds
- use prop mangling for smaller builds
- fast class / object test
- updaters
inc1
,inc
,push
,set
,delete
,assign
,toggle
- utils
assignVals
, `toJS - setter for
drv
? - host docs
- check https://reactpixi.org/#/stage / https://docs.setprotocol.com/#/#support-and-community- for setup of edit button, menu nesting, hosting
-
sub
, pass in previous value as second argument - implement
SubscribeOptions
- keepAlive drv option, using effect
- publish all script
- tests and types for utils
- kill with-immmer?
- improve updaters typings
- verify callign actions in reactions work correctly
- move
invariant
to preprocessors? - add
toJS
on all model types - rval-validation
- kill
run
- fix debugging with minification
- use yalc? https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fwhitecolor%2Fyalc%2F&sa=D&sntz=1&usg=AFQjCNGCTXoCduIMdVHx5xm-uAs_REX3MA
- add missing mobx optimizations
- contributing and debugging
- docs
- add
reference
to models? - contributing & debugging guide.
reserved
section in package.json! - add (mobx like) performance tests
- rval.js.org CDN
- smart lack of act detection. Only have
act
, norun
? - rename MDX files to md
- rview as wrapper
- deep merge model tree?
- RVAL return this in setter for chaining?
- cheat sheet
- efficient map structure
- find neat solution to globally shared instance
Later
- rval-remote
- config: warn on unbatched writes
- config: warn on untracked, stale reads
- strict mode: only reads from actions or reactions. Only updates from actions.
- eliminate classes from code base
-
drv(( tick ) => ())
to communicate staleness from inside drv (probably also needs onHot / onCold callback in such case) - dynamically switch between hook and non-hook implementations (and explain differences)
- support name option
- abstraction for creating drv / vals and subscribing in hook based component automatically?
- MobX global state compatibility?