FRPtools container hash function is now optional

This commit is contained in:
Timothy Farrell 2018-09-11 13:07:58 -05:00
parent ccd6410c28
commit 90461529d6
3 changed files with 6 additions and 6 deletions

View File

@ -190,8 +190,8 @@ them.
## Behavior
Anytime a property is set or a method is gotten and called, the container will check for an updated
state and trigger subscribers if it is updated. An hash function must be applied to determine
updated status.
state and trigger subscribers if it is updated. An optional hash function may be applied to
determine updated status. If the hash function is not supplied, every update will be propagated.
## Usage

View File

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

View File

@ -2,7 +2,7 @@ import { registerSubscriptions, registerFire } from './util.js';
export function container(store, hash) {
let subscribers = [];
let id = hash(store);
let id = hash && hash(store);
const containerMethods = {
subscribe: registerSubscriptions(subscribers),
@ -13,8 +13,8 @@ export function container(store, hash) {
};
function checkUpdate(target) {
const newId = hash(target);
if (id !== newId) {
let newId = hash && hash(target);
if (!hash || id !== newId) {
id = newId;
containerMethods.fire(target);
}