Skip to content

Commit

Permalink
Fixed test build
Browse files Browse the repository at this point in the history
  • Loading branch information
mweststrate committed Dec 20, 2018
1 parent f132766 commit 0d1ba6f
Show file tree
Hide file tree
Showing 12 changed files with 171 additions and 148 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ Todo:
* [ ] support `this.rvalProps(this.rvalProps() + 1)` -> `this.rvalProps(x => x + 1)`?
* [ ] updaters `inc1`, `inc`, `push`, `set`, `delete`, `assign`, `toggle`
* [ ] utils `assignVals`, `toJS
* [ ] move `invariant` to preprocessors?
* [ ] add `reference` to models?
* [ ] host docs
* [ ] contributing guide. `reserved` section in package.json!
* [ ] add `toJS` on all model types

Later
* [ ] dynamically switch between hook and non-hook implementations (and explain differences)
Expand Down
12 changes: 9 additions & 3 deletions docs/0_introduction/00_about.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ route: /introduction/introduction

# About RVal

RVal is a minimalistic, transparent programming library, heavily inspired by [MobX](http://mobx.js.org),
RVal is a minimalistic, transparent reactive programming library, heavily inspired by [MobX](http://mobx.js.org),
with the same core principle: _Everything that can be derived from state, should be derived. Automatically_.

However, the goals are slightly different. RVal core principles include:
Expand All @@ -17,10 +17,16 @@ However, the goals are slightly different. RVal core principles include:
* 🎯 **Convention driven**: An idiomatic way of working, that guides devs into the [Pit of Success](https://medium.com/@ricomariani/the-pit-of-success-cfefc6cb64c8)
* 📦 **Embeddable**: A low level building block, that is small (~2KB minified gzipped) so that it can easily be embedded in existing libraries and frameworks as state management libraries.
* 🐆 **Fast**: Rock solid performance, leveraging the battle tested algorithms of MobX.
***Versatile**: no dependencies, no modern syntax requirements, non-intrusive, applicable in most JavaScript based stacks
***Versatile**: no dependencies, no modern syntax or language requirements, non-intrusive, applicable in any ES5 JavaScript stack
* 🎓 **Gradual learning curve**: Opt-in utilities that help with applying best practices
* 💪 **Strongly typed**: Shouldn't need further explanation in 2019

## Quick example

TODO
TODO

## Packages

TODO

Table, with name, goal, cdn, umdname, bundlesize
4 changes: 0 additions & 4 deletions pkgs/core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,6 @@ function removeCallback(fns: Thunk[], fn: Thunk) {
fns.splice(fns.indexOf(fn), 1) // TODO: defensive index check?
}

export function toJS(value) {
// convert, recursively, all own enumerable, primitive + vals values
}

export function isVal(value: any): value is Val {
return typeof value === "function" && value[$RVal] instanceof ObservableValue
}
Expand Down
51 changes: 35 additions & 16 deletions pkgs/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@r-val/core",
"private": false,
"version": "0.0.1",
"description": "",
"description": "minimalistic, transparent reactive programming library",
"main": "dist/core.js",
"umd:main": "dist/core.umd.js",
"unpkg": "dist/core.umd.js",
Expand All @@ -18,28 +18,47 @@
"author": "Michel Weststrate",
"license": "MIT",
"dependencies": {},
"files": ["*.ts", "dist"],
"files": [
"*.ts",
"dist"
],
"devDependencies": {},
"reserved": [
"configurable",
"enumerable",
"writable",
"value",
"$RVal",
"rval",
"defaultContext",
"isVal",
"isDrv",
"deepfreeze",
"val",
"drv",
"sub",
"batch",
"batched",
"effect"
],
"mangle": {
"reserved": [
"configurable",
"enumerable",
"writable",
"value",
"$RVal",
"rval",
"defaultContext",
"isVal",
"isDrv",
"deepfreeze",
"val",
"drv",
"sub",
"batch",
"batched",
"deepfreeze",
"isVal",
"isDrv",
"defaultContext",
"rval",
"rview",
"useVal",
"useLocalVal",
"useLocalDrv",
"model",
"mapOf",
"arrayOf",
"updater"
"effect"
]
}
}
}
9 changes: 4 additions & 5 deletions pkgs/core/tests/scheduling.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { val, sub, drv, batch, effect } from '@r-val/core'
import { val, sub, drv, batch, effect, $RVal } from '@r-val/core'

const RVAL = Symbol.for('$RVal')
function getDeps(thing) {
return Array.from(thing[RVAL].listeners)
return Array.from(thing[$RVal].listeners)
}

async function delay(time) {
Expand Down Expand Up @@ -63,10 +62,10 @@ test("scheduling 1", async () => {
await delay(50)
expect(events.splice(0)).toEqual([ ])

if (y[RVAL].markDirty) {
if (y[$RVal].markDirty) {
// only check on non-minified build
// should be exactly one dependency
expect(getDeps(x)).toEqual([y[RVAL].markDirty])
expect(getDeps(x)).toEqual([y[$RVal].markDirty])
}
x(4)
expect(events.splice(0)).toEqual([
Expand Down
2 changes: 1 addition & 1 deletion pkgs/immer/immer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { rval, Val } from "@r-val/core"
import produce, { Draft } from "immer"
import { produce, Draft } from "immer"

export function updater<T, U extends any[], R>(val: Val<T>, updater: (draft: Draft<T>, ...args: U) => R): (...args: U) => R {
return function(...args: U) {
Expand Down
40 changes: 25 additions & 15 deletions pkgs/immer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,38 @@
"author": "Michel Weststrate",
"license": "MIT",
"dependencies": {},
"files": ["*.ts", "dist"],
"files": [
"*.ts",
"dist"
],
"devDependencies": {},
"peerDependencies": {
"immer": "^1.6.0"
},
"reserved": [
"updater",
"produce"
],
"mangle": {
"reserved": [
"configurable",
"enumerable",
"writable",
"value",
"$RVal",
"rval",
"defaultContext",
"isVal",
"isDrv",
"deepfreeze",
"val",
"drv",
"sub",
"batch",
"batched",
"deepfreeze",
"isVal",
"isDrv",
"defaultContext",
"rval",
"rview",
"useVal",
"useLocalVal",
"useLocalDrv",
"model",
"mapOf",
"arrayOf",
"updater"
"effect",
"updater",
"produce"
]
}
}
}
35 changes: 23 additions & 12 deletions pkgs/models/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,39 @@
"author": "Michel Weststrate",
"license": "MIT",
"dependencies": {},
"files": ["*.ts", "dist"],
"files": [
"*.ts",
"dist"
],
"devDependencies": {},
"reserved": [
"model",
"mapOf",
"arrayOf",
"invariant"
],
"mangle": {
"reserved": [
"configurable",
"enumerable",
"writable",
"value",
"$RVal",
"rval",
"defaultContext",
"isVal",
"isDrv",
"deepfreeze",
"val",
"drv",
"sub",
"batch",
"batched",
"deepfreeze",
"isVal",
"isDrv",
"defaultContext",
"rval",
"rview",
"useVal",
"useLocalVal",
"useLocalDrv",
"effect",
"model",
"mapOf",
"arrayOf",
"updater"
"invariant"
]
}
}
}
45 changes: 0 additions & 45 deletions pkgs/package-template.json

This file was deleted.

34 changes: 9 additions & 25 deletions pkgs/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,12 @@
"author": "Michel Weststrate",
"license": "MIT",
"dependencies": {},
"files": ["*.ts", "dist"],
"devDependencies": {},
"mangle": {
"reserved": [
"val",
"drv",
"sub",
"batch",
"batched",
"deepfreeze",
"isVal",
"isDrv",
"defaultContext",
"rval",
"rview",
"useVal",
"useLocalVal",
"useLocalDrv",
"model",
"mapOf",
"arrayOf",
"updater"
]
}
}
"peerDependencies": {
"react": "^16.0.0"
},
"files": [
"*.ts",
"dist"
],
"devDependencies": {}
}
Loading

0 comments on commit 0d1ba6f

Please sign in to comment.