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",
"version": "3.1.0",
"version": "3.1.1",
"description": "Observable Property and Computed data streams",
"main": "src/index.js",
"files": ["src"],

View File

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

View File

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