Skip to content

Commit bba5d9e

Browse files
committed
Major updates for v0.11.0
1 parent c4323e9 commit bba5d9e

16 files changed

+601
-1530
lines changed

README.md

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,32 +34,19 @@ module.exports = {
3434
output: 'path-to-output/filename.js',
3535
variables: {
3636
imports: [ `import S from 's-js'` ],
37-
computed: 'S',
38-
sample: 'S.sample',
39-
root: 'S.root',
40-
cleanup: 'S.cleanup'
37+
declarations: {
38+
wrap: 'S',
39+
}
4140
}
4241
}
4342
```
4443

4544
These symbols should reference an observable API with the following functionality:
4645

47-
### computed(fn) : void
46+
### wrap(fn) : void
4847

4948
This is used to wrap all expressions in computations. Your wrap method is expected to call fn with the previously evaluated value if the arity is 1 to allow for reducing computations.
5049

51-
### root(fn) : any
52-
53-
This indicates a new disposable context. The fn should be provided a dispose method that can be called to free all computations in the context.
54-
55-
### sample(fn) : any
56-
57-
A method that causes dependencies within not to be tracked.
58-
59-
### cleanup(fn) : void
60-
61-
This method should register a cleanup method to be called when the context is released.
62-
6350
Then you run the cli command:
6451
```sh
6552
> dom-expressions

babel.config.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
// babel.config.js
21
module.exports = {
3-
presets: [['@babel/preset-env', {targets: {node: 'current'}}]],
4-
plugins: [['babel-plugin-jsx-dom-expressions', {moduleName: './runtime.js'}]]
2+
env: {
3+
test: {
4+
presets: [['@babel/preset-env', {targets: {node: 'current'}}]],
5+
plugins: [['babel-plugin-jsx-dom-expressions', {moduleName: './runtime.js', alwaysCreateComponents: true}]]
6+
}
7+
}
58
};

dom-expressions.config.js

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,9 @@ module.exports = {
22
output: 'test/runtime.js',
33
variables: {
44
imports: [ `import {
5-
comp as wrap, sample, root, cleanup, getContextOwner as currentContext,
6-
setContext, makeDataNode, value
5+
comp as wrap, getContextOwner as currentContext,
76
} from '@ryansolid/s-js'` ],
8-
declarations: {
9-
memo: `(fn) => {
10-
const s = value(fn());
11-
wrap(() => s(fn()));
12-
return s;
13-
}`,
14-
SuspenseContext: `{
15-
id: 'suspense', initFn: () => {
16-
let counter = 0;
17-
const s = makeDataNode(),
18-
store = {
19-
increment: () => ++counter === 1 && !store.initializing && s.next(),
20-
decrement: () => --counter === 0 && s.next(),
21-
suspended: () => {
22-
s.current();
23-
return counter;
24-
},
25-
initializing: true
26-
}
27-
return store;
28-
}
29-
}`,
30-
registerSuspense: `(fn) => {
31-
wrap(() => {
32-
const c = SuspenseContext.initFn();
33-
setContext(SuspenseContext.id, c);
34-
fn(c);
35-
c.initializing = false;
36-
});
37-
}`
38-
},
39-
includeContext: true
7+
includeContext: true,
8+
classComponents: true
409
}
4110
}

0 commit comments

Comments
 (0)