Clear up varname confusion.

This commit is contained in:
Timothy Farrell 2018-03-31 15:34:28 -05:00
parent 3d6037cd05
commit 6209aae878
4 changed files with 8 additions and 8 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "frptools", "name": "frptools",
"version": "3.1.0", "version": "3.1.1",
"description": "Observable Property and Computed data streams", "description": "Observable Property and Computed data streams",
"main": "src/index.js", "main": "src/index.js",
"files": ["src"], "files": ["src"],

View File

@ -4,7 +4,7 @@ export function computed(fn, dependencies = [], hash = id) {
let subscribers = []; let subscribers = [];
let isDirty = true; let isDirty = true;
let val; let val;
let id; let oldId;
// Compute new value, call subscribers if changed. // Compute new value, call subscribers if changed.
const accessor = function _computed() { const accessor = function _computed() {
@ -12,8 +12,8 @@ export function computed(fn, dependencies = [], hash = id) {
const newVal = fn.apply(null, dependencies.map(runParam)); const newVal = fn.apply(null, dependencies.map(runParam));
isDirty = false; isDirty = false;
const newId = hash(newVal); const newId = hash(newVal);
if (id !== newId) { if (oldId !== newId) {
id = newId; oldId = newId;
val = newVal; val = newVal;
accessor.fire(val); accessor.fire(val);
} }

View File

@ -1,4 +1,4 @@
import { id, registerSubscriptions, registerFire } from './util.js'; import { registerSubscriptions, registerFire } from './util.js';
export function container(store, hash) { export function container(store, hash) {
let subscribers = []; let subscribers = [];

View File

@ -2,12 +2,12 @@ import { id, registerSubscriptions, registerFire } from './util.js';
export function prop(store, hash = id) { export function prop(store, hash = id) {
let subscribers = []; let subscribers = [];
let id = hash(store); let oldId = hash(store);
const accessor = function _prop(newVal) { const accessor = function _prop(newVal) {
const newId = hash(newVal); const newId = hash(newVal);
if (newVal !== undefined && id !== newId) { if (newVal !== undefined && oldId !== newId) {
id = newId; oldId = newId;
store = newVal; store = newVal;
accessor.fire(store); accessor.fire(store);
} }