Clear up varname confusion.
This commit is contained in:
parent
4923844527
commit
ad779629a5
@ -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"],
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { id, registerSubscriptions, registerFire } from './util.js';
|
||||
import { registerSubscriptions, registerFire } from './util.js';
|
||||
|
||||
export function container(store, hash) {
|
||||
let subscribers = [];
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user