Skip to content

Commit

Permalink
Processed bunch of todo's
Browse files Browse the repository at this point in the history
  • Loading branch information
mweststrate committed Dec 27, 2018
1 parent a824fe9 commit d2080c1
Show file tree
Hide file tree
Showing 22 changed files with 1,990 additions and 179 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ dist
.rts2_cache*
/coverage
.docz
mangle.json
mangle.json
lerna-debug.log
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@

[![npm](https://img.shields.io/npm/v/rval.svg)](https://www.npmjs.com/package/rval) [![size](http://img.badgesize.io/https://unpkg.com/rval/dist/core.mjs?compression=gzip)](http://img.badgesize.io/https://unpkg.com/rval/dist/core.mjs?compression=gzip) [![Build Status](https://travis-ci.org/mweststrate/rval.svg?branch=master)](https://travis-ci.org/mweststrate/rval) [![Coverage Status](https://coveralls.io/repos/github/mweststrate/rval/badge.svg?branch=master)](https://coveralls.io/github/mweststrate/rval?branch=master) [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/michelweststrate) [![Donate](https://img.shields.io/badge/donate-buy%20me%20a%20coffee-orange.svg)](https://www.buymeacoffee.com/mweststrate)

TODO: publish docz docs somewhere and link

[Philosophy](docs/philosophy.mdx)
[Getting Started](docs/getting-started.mdx)
Docs in progress:

https://mweststrate.github.io/rval

STATE DESIGN

Expand Down Expand Up @@ -131,29 +130,31 @@ Todo:
* [x] setter for `drv`?
* [x] host docs
* [x] check https://reactpixi.org/#/stage / https://docs.setprotocol.com/#/#support-and-community- for setup of edit button, menu nesting, hosting
* [ ] config: warn on unbatched writes
* [ ] config: warn on untracked, stale reads
* [x] `sub`, pass in previous value as second argumetn
* [x] implement `SubscribeOptions`
* [x] keepAlive drv option, using effect
* [x] publish all script
* [ ] rval-validation
* [ ] strict mode: only reads from actions or reactions. Only updates from actions.
* [ ] verify callign actions in reactions work correctly
* [ ] contributing and debugging
* [ ] docs
* [ ] implement `SubscribeOptions`
* [ ] verify debugging with minification
* [ ] tests and types for utils
* [ ] move `invariant` to preprocessors?
* [ ] add `reference` to models?
* [ ] contributing guide. `reserved` section in package.json!
* [ ] contributing & debugging guide. `reserved` section in package.json!
* [ ] add `toJS` on all model types
* [ ] add (mobx like) performance tests
* [ ] kill with-immmer?
* [ ] `sub`, pass in previous value as second argumetn
* [ ] improve updaters typings
* [ ] publish all script
* [ ] rval.js.org CDN
* [ ] use yalc? https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fwhitecolor%2Fyalc%2F&sa=D&sntz=1&usg=AFQjCNGCTXoCduIMdVHx5xm-uAs_REX3MA

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)
Expand Down
28 changes: 27 additions & 1 deletion docs_source/0_introduction/20_objects-and-factories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,33 @@ This holds for many updaters. For example `inc` (to increment), `set`, `splice`
to manipulate objects or arrays take arguments as well.
You'll find it is pretty trivial to write your own updater function (feel free to [PR](https://github.com/mweststrate/rval/compare)!).
But here is the extensive list all [updaters](#/api/updaters).
But here is the extensive list all [updaters](#/api/updaters) provided by the `@r-val/updaters` package.
Note that the `@r-val/updaters` package is just a set of convenient update functions!
However, because the signature of an updater is just a pure function that takes some old state, and produces some new state,
you can leverage any package you are familiar with to model an update! Such as `ramda` or `immer`. For example:
```javascript
import { val } from "@r-val/core"
import { append } from "ramda"
test("it should append with ramda", () => {
const numbers = val([1,2])
numbers(append(3))
expect(numbers()).toEqual([1,2,3])
})
```
```javascript
import { val } from "@r-val/core"
import produce from "immer"
test("it should produce with immer", () => {
const numbers = val([1,2])
numbers(produce(draft => { draft.push(3) }))
expect(numbers()).toEqual([1,2,3])
})
```
_Tip: You might be wondering, if any function that is passed as value to a reactive value is called, how do I store function `fn` in reactive value `x`? The answer is simple: just pass a function that produces `fn`. So instead of `x(fn)` use `x(() => fn)`. Or you can use the built-in updater `replace` to achieve the same: `x(replace(fn))`._
Expand Down
21 changes: 21 additions & 0 deletions docs_source/0_introduction/30_with-react.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,24 @@ menu: Introduction
route: /introduction/react
---

```javascript
const counter = val(0)

const Counter = () => {
const c = useVal(counter)
<div>
{c}
<button onClick={() => counter(0)}>
Reset
</button>
</div>
}

setInterval(() => {
counter(c => c + 1)
}, 1000);

render(<Counter />, document.body)
```

// Sandbox
14 changes: 14 additions & 0 deletions docs_source/1_advanced/organizing_state.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Designing the state shape
order: 3
menu: Advanced
route: /advanced/state-design
---

# Designing the state shape

## Choosing immutability granularity level

## Composition, normalization and association

## Working with references
6 changes: 6 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"packages": [
"pkgs/*"
],
"version": "0.0.4"
}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"test": "jest --config jest.config.test.json",
"coverage": "jest --runInBand --coverage --config jest.config.json && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"docz:dev": "docz dev",
"docz:build": "docz build"
"docz:build": "docz build",
"release": "yarn build && lerna publish && yarn docz:build && git add docs && git commit -m 'regenned docs'"
},
"author": "Michel Weststrate",
"license": "MIT",
"dependencies": {},
"files": [
"core",
"immer",
Expand All @@ -38,8 +38,10 @@
"docz-theme-default": "^0.13.4",
"immer": "^1.9.3",
"jest": "^23.6.0",
"lerna": "^3.8.0",
"microbundle": "^0.9.0",
"prettier": "^1.15.2",
"ramda": "^0.26.1",
"react": "^16.7.0-alpha.2",
"react-dom": "^16.7.0-alpha.2",
"react-testing-library": "^5.4.0",
Expand Down
Loading

0 comments on commit d2080c1

Please sign in to comment.