FRPtools container hash function is now optional
This commit is contained in:
parent
9597b52941
commit
12600453a7
@ -190,8 +190,8 @@ them.
|
|||||||
## Behavior
|
## Behavior
|
||||||
|
|
||||||
Anytime a property is set or a method is gotten and called, the container will check for an updated
|
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
|
state and trigger subscribers if it is updated. An optional hash function may be applied to
|
||||||
updated status.
|
determine updated status. If the hash function is not supplied, every update will be propagated.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "frptools",
|
"name": "frptools",
|
||||||
"version": "3.2.2",
|
"version": "3.2.3",
|
||||||
"description": "Observable Property and Computed data streams",
|
"description": "Observable Property and Computed data streams",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"files": [
|
"files": [
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { registerSubscriptions, registerFire } from './util.js';
|
|||||||
|
|
||||||
export function container(store, hash) {
|
export function container(store, hash) {
|
||||||
let subscribers = [];
|
let subscribers = [];
|
||||||
let id = hash(store);
|
let id = hash && hash(store);
|
||||||
|
|
||||||
const containerMethods = {
|
const containerMethods = {
|
||||||
subscribe: registerSubscriptions(subscribers),
|
subscribe: registerSubscriptions(subscribers),
|
||||||
@ -13,8 +13,8 @@ export function container(store, hash) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function checkUpdate(target) {
|
function checkUpdate(target) {
|
||||||
const newId = hash(target);
|
let newId = hash && hash(target);
|
||||||
if (id !== newId) {
|
if (!hash || id !== newId) {
|
||||||
id = newId;
|
id = newId;
|
||||||
containerMethods.fire(target);
|
containerMethods.fire(target);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user