remove oldState from recompute

pull/856/head
Rich Harris 7 years ago
parent 955354739f
commit 6f0961ed5a

@ -97,9 +97,9 @@ export default function dom(
const condition = `${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}, (state.${key} = @template.computed.${key}(${deps
.map(dep => `state.${dep}`) .map(dep => `state.${dep}`)
.join(', ')})), oldState.${key})) changed.${key} = true;`; .join(', ')})))) changed.${key} = true;`;
computationBuilder.addConditional(condition, statement); computationBuilder.addConditional(condition, statement);
}); });
@ -165,7 +165,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({ ${Array.from(computationDeps).map(dep => `${dep}: 1`).join(', ')} }, this._state, {});`} ${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 =>
@ -303,7 +303,7 @@ export default function dom(
`} `}
${computations.length ? deindent` ${computations.length ? deindent`
${name}.prototype._recompute = function _recompute(changed, state, oldState) { ${name}.prototype._recompute = function _recompute(changed, state) {
${computationBuilder} ${computationBuilder}
} }
` : (!sharedPath && `${name}.prototype._recompute = @noop;`)} ` : (!sharedPath && `${name}.prototype._recompute = @noop;`)}

@ -155,7 +155,7 @@ export function _set(newState) {
if (!dirty) return; if (!dirty) return;
this._state = assign({}, oldState, newState); this._state = assign({}, oldState, newState);
this._recompute(changed, this._state, oldState, false); this._recompute(changed, this._state);
if (this._bind) this._bind(changed, this._state); if (this._bind) this._bind(changed, this._state);
dispatchObservers(this, this._observers.pre, changed, this._state, oldState); dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
this._fragment.update(changed, this._state); this._fragment.update(changed, this._state);

Loading…
Cancel
Save