Comparing version 0.0.11 to 0.0.12
import { createRuntime } from 'babel-plugin-jsx-dom-expressions'; | ||
import { S, unwrap, from } from 'solid-js'; | ||
import S from 's-js'; | ||
import { unwrap, from } from 'solid-js'; | ||
function handleEvent(handler, id) { | ||
return e => { | ||
return function(e) { | ||
let node = e.target, | ||
name = `__ev$${e.type}`; | ||
while (node && node !== this && !(node[name])) node = node.parentNode; | ||
if (!node || node === this) return; | ||
if (node[name] && node[name + 'Id'] === id) handler(node[name], e); | ||
@@ -40,3 +42,3 @@ } | ||
fn = handleEvent(handler, eId); | ||
S.cleanup(() => attached.removeEventListener(eventName, fn)); | ||
S.cleanup(() => attached && attached.removeEventListener(eventName, fn)); | ||
return data => element => { | ||
@@ -43,0 +45,0 @@ element[`__ev$${eventName}`] = data; |
import S from 's-js'; | ||
export { default as S } from 's-js'; | ||
import $$observable$1 from 'symbol-observable'; | ||
@@ -575,7 +574,7 @@ | ||
input = from(input); | ||
return S(() => { | ||
return () => { | ||
const value = input(); | ||
if (value === void 0) return; | ||
return S.sample(() => fn(value)); | ||
}); | ||
}; | ||
}; | ||
@@ -600,10 +599,8 @@ } | ||
length = 0; | ||
S.makeComputationNode(function disposer() { | ||
S.cleanup(function dispose() { | ||
for (let i = 0; i < disposables.length; i++) disposables[i](); | ||
}); | ||
S.cleanup(function dispose() { | ||
for (let i = 0; i < disposables.length; i++) disposables[i](); | ||
}); | ||
return map(function mapper(newList) { | ||
let newListUnwrapped = unwrap(newList), | ||
i, j, newLength, start, end, newEnd, item, itemIndex, newMapped, | ||
i, j = 0, newLength, start, end, newEnd, item, itemIndex, newMapped, | ||
indexedItems, tempDisposables; | ||
@@ -625,15 +622,5 @@ // Non-Arrays | ||
list[0] = newListUnwrapped; | ||
return mapped[0] = S.root(function disposer(dispose) { | ||
disposables[0] = dispose; | ||
return mapFn(newList); | ||
}); | ||
return mapped[0] = S.root(mappedFn); | ||
} | ||
function mappedFn(dispose) { | ||
let ref; | ||
disposables[j] = dispose; | ||
const row = (ref = newList.sample) ? ref(j) : newList[j]; | ||
return mapFn(row, j); | ||
} | ||
newLength = newListUnwrapped.length; | ||
@@ -714,2 +701,9 @@ if (newLength === 0) { | ||
return mapped; | ||
function mappedFn(dispose) { | ||
let ref; | ||
disposables[j] = dispose; | ||
const row = (ref = newList.sample) ? ref(j) : newList[j]; | ||
return mapFn(row, j); | ||
} | ||
}); | ||
@@ -740,2 +734,4 @@ } | ||
export { State, ImmutableState, unwrap, from, map, pipe, memo, observable }; | ||
const root = S.root; | ||
export { root, State, ImmutableState, unwrap, from, map, pipe, memo, observable }; |
@@ -8,3 +8,3 @@ # Signals | ||
```js | ||
import { S } from 'solid-js'; | ||
import S from 's-js'; | ||
@@ -25,3 +25,4 @@ function fromInterval(delay) { | ||
```js | ||
import { S, State } from 'solid-js'; | ||
import S from 's-js'; | ||
import { State } from 'solid-js'; | ||
@@ -103,6 +104,6 @@ state = new State({count: 1}); | ||
To write your own pipeable operator involves creating a function that returns a function that takes a Signal and returns a new Signal. Generally it looks like this: | ||
To write your own pipeable operator involves creating a function that returns a function that takes a thunk and returns a new thunk. Generally it looks like this: | ||
```js | ||
import { S, pipe, map, from } from 'solid-js'; | ||
import { pipe, map, from } from 'solid-js'; | ||
@@ -113,4 +114,4 @@ function someOperator(...someArguments) { | ||
input = from(input) | ||
return S(() => | ||
//...do some calculation | ||
return () => | ||
//...do some calculation based on input | ||
) | ||
@@ -117,0 +118,0 @@ } |
@@ -5,10 +5,14 @@ 'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var babelPluginJsxDomExpressions = require('babel-plugin-jsx-dom-expressions'); | ||
var S = _interopDefault(require('s-js')); | ||
var solidJs = require('solid-js'); | ||
function handleEvent(handler, id) { | ||
return e => { | ||
return function(e) { | ||
let node = e.target, | ||
name = `__ev$${e.type}`; | ||
while (node && node !== this && !(node[name])) node = node.parentNode; | ||
if (!node || node === this) return; | ||
if (node[name] && node[name + 'Id'] === id) handler(node[name], e); | ||
@@ -25,3 +29,3 @@ } | ||
wrap(el, accessor, isAttr, fn, deep) { | ||
solidJs.S.makeComputationNode(() => { | ||
S.makeComputationNode(() => { | ||
let value = accessor(); | ||
@@ -36,3 +40,3 @@ if ((value != null) && value instanceof Object) { | ||
} | ||
solidJs.S.sample(() => fn(el, value)); | ||
S.sample(() => fn(el, value)); | ||
}); | ||
@@ -47,3 +51,3 @@ } | ||
fn = handleEvent(handler, eId); | ||
solidJs.S.cleanup(() => attached.removeEventListener(eventName, fn)); | ||
S.cleanup(() => attached && attached.removeEventListener(eventName, fn)); | ||
return data => element => { | ||
@@ -63,3 +67,3 @@ element[`__ev$${eventName}`] = data; | ||
let index = []; | ||
solidJs.S.on(signal, prev => { | ||
S.on(signal, prev => { | ||
let id = signal(); | ||
@@ -72,3 +76,3 @@ if (prev != null && index[prev]) handler(index[prev], false); | ||
index[id] = element; | ||
solidJs.S.cleanup(() => index[id] = null); | ||
S.cleanup(() => index[id] = null); | ||
} | ||
@@ -79,3 +83,3 @@ } | ||
let index = []; | ||
solidJs.S.on(signal, prev => { | ||
S.on(signal, prev => { | ||
let value = signal(); | ||
@@ -89,3 +93,3 @@ [additions, removals] = shallowDiff(value, prev); | ||
index[id] = element; | ||
solidJs.S.cleanup(() => index[id] = null); | ||
S.cleanup(() => index[id] = null); | ||
} | ||
@@ -92,0 +96,0 @@ } |
@@ -580,7 +580,7 @@ 'use strict'; | ||
input = from(input); | ||
return S(() => { | ||
return () => { | ||
const value = input(); | ||
if (value === void 0) return; | ||
return S.sample(() => fn(value)); | ||
}); | ||
}; | ||
}; | ||
@@ -605,10 +605,8 @@ } | ||
length = 0; | ||
S.makeComputationNode(function disposer() { | ||
S.cleanup(function dispose() { | ||
for (let i = 0; i < disposables.length; i++) disposables[i](); | ||
}); | ||
S.cleanup(function dispose() { | ||
for (let i = 0; i < disposables.length; i++) disposables[i](); | ||
}); | ||
return map(function mapper(newList) { | ||
let newListUnwrapped = unwrap(newList), | ||
i, j, newLength, start, end, newEnd, item, itemIndex, newMapped, | ||
i, j = 0, newLength, start, end, newEnd, item, itemIndex, newMapped, | ||
indexedItems, tempDisposables; | ||
@@ -630,15 +628,5 @@ // Non-Arrays | ||
list[0] = newListUnwrapped; | ||
return mapped[0] = S.root(function disposer(dispose) { | ||
disposables[0] = dispose; | ||
return mapFn(newList); | ||
}); | ||
return mapped[0] = S.root(mappedFn); | ||
} | ||
function mappedFn(dispose) { | ||
let ref; | ||
disposables[j] = dispose; | ||
const row = (ref = newList.sample) ? ref(j) : newList[j]; | ||
return mapFn(row, j); | ||
} | ||
newLength = newListUnwrapped.length; | ||
@@ -719,2 +707,9 @@ if (newLength === 0) { | ||
return mapped; | ||
function mappedFn(dispose) { | ||
let ref; | ||
disposables[j] = dispose; | ||
const row = (ref = newList.sample) ? ref(j) : newList[j]; | ||
return mapFn(row, j); | ||
} | ||
}); | ||
@@ -745,3 +740,5 @@ } | ||
exports.S = S; | ||
const root = S.root; | ||
exports.root = root; | ||
exports.State = State; | ||
@@ -748,0 +745,0 @@ exports.ImmutableState = ImmutableState; |
{ | ||
"name": "solid-js", | ||
"description": "A declarative JavaScript library for building user interfaces.", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"author": "Ryan Carniato", | ||
@@ -22,3 +22,3 @@ "license": "MIT", | ||
"peerDependencies": { | ||
"babel-plugin-jsx-dom-expressions": "~0.0.23", | ||
"babel-plugin-jsx-dom-expressions": "~0.0.25", | ||
"s-js": "~0.4.9" | ||
@@ -25,0 +25,0 @@ }, |
@@ -43,3 +43,3 @@ # Solid.js | ||
S.root(() => mountEl.appendChild(<MyComponent />)); | ||
root(() => mountEl.appendChild(<MyComponent />)); | ||
``` | ||
@@ -46,0 +46,0 @@ |
@@ -1,2 +0,3 @@ | ||
const { S, ImmutableState } = require('../lib/solid'); | ||
const S = require('s-js'); | ||
const { ImmutableState } = require('../lib/solid'); | ||
@@ -3,0 +4,0 @@ describe('state.set', () => { |
@@ -1,2 +0,3 @@ | ||
const { S, from } = require('../lib/solid'); | ||
const S = require('s-js'); | ||
const { from } = require('../lib/solid'); | ||
const Observable = require('zen-observable'); | ||
@@ -18,3 +19,3 @@ | ||
setTimeout(s, 20, 'started'); | ||
S.root(async () => { | ||
S.root(() => { | ||
var out = from(s); | ||
@@ -21,0 +22,0 @@ expect(out()).toBe('init'); |
@@ -1,2 +0,3 @@ | ||
const { S, State } = require('../lib/solid'); | ||
const S = require('s-js'); | ||
const { State } = require('../lib/solid'); | ||
@@ -3,0 +4,0 @@ describe('state.set', () => { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
91975
2045