Clear up varname confusion.
This commit is contained in:
parent
4923844527
commit
ad779629a5
@ -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"],
|
||||||
|
|||||||
@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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 = [];
|
||||||
|
|||||||
@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user