remove isInitial check on recompute

pull/856/head
Rich Harris 8 years ago
parent ba447f7067
commit 9f19121b65

@ -77,9 +77,14 @@ export default function dom(
const builder = new CodeBuilder(); const builder = new CodeBuilder();
const computationBuilder = new CodeBuilder(); const computationBuilder = new CodeBuilder();
const computationDeps = new Set();
if (computations.length) { if (computations.length) {
computations.forEach(({ key, deps }) => { computations.forEach(({ key, deps }) => {
deps.forEach(dep => {
computationDeps.add(dep);
});
if (generator.readonly.has(key)) { if (generator.readonly.has(key)) {
// <:Window> bindings // <:Window> bindings
throw new Error( throw new Error(
@ -89,7 +94,7 @@ export default function dom(
generator.readonly.add(key); generator.readonly.add(key);
const condition = `isInitial || ${deps.map(dep => `changed.${dep}`).join(' || ')}`; const condition = `${deps.map(dep => `changed.${dep}`).join(' || ')}`;
const statement = `if (@differs((state.${key} = @template.computed.${key}(${deps const statement = `if (@differs((state.${key} = @template.computed.${key}(${deps
.map(dep => `state.${dep}`) .map(dep => `state.${dep}`)
@ -159,7 +164,7 @@ export default function dom(
? `@assign(@template.data(), options.data)` ? `@assign(@template.data(), options.data)`
: `options.data || {}`}; : `options.data || {}`};
${generator.metaBindings} ${generator.metaBindings}
${computations.length && `this._recompute({}, this._state, {}, true);`} ${computations.length && `this._recompute({ ${Array.from(computationDeps).map(dep => `${dep}: 1`).join(', ')} }, this._state, {});`}
${options.dev && ${options.dev &&
Array.from(generator.expectedProperties).map( Array.from(generator.expectedProperties).map(
prop => prop =>
@ -306,7 +311,7 @@ export default function dom(
`} `}
${computations.length ? deindent` ${computations.length ? deindent`
${name}.prototype._recompute = function _recompute(changed, state, oldState, isInitial) { ${name}.prototype._recompute = function _recompute(changed, state, oldState) {
${computationBuilder} ${computationBuilder}
} }
` : (!sharedPath && `${name}.prototype._recompute = @noop;`)} ` : (!sharedPath && `${name}.prototype._recompute = @noop;`)}

Loading…
Cancel
Save