treble-hook
Advanced tools
Comparing version 0.0.14 to 0.0.15
@@ -0,1 +1,6 @@ | ||
export declare enum TupleIndex { | ||
State = 0, | ||
Publish = 1, | ||
Unsubscribe = 2 | ||
} | ||
export declare function usePubSub<T>(topic: string, defaultState: T): SubscriptionTuple<T>; | ||
@@ -2,0 +7,0 @@ declare type Publish<T> = (newState: T) => void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const react_1 = require("react"); | ||
const HOOK_PUBLISH_INDEX = 1; | ||
var TupleIndex; | ||
(function (TupleIndex) { | ||
TupleIndex[TupleIndex["State"] = 0] = "State"; | ||
TupleIndex[TupleIndex["Publish"] = 1] = "Publish"; | ||
TupleIndex[TupleIndex["Unsubscribe"] = 2] = "Unsubscribe"; | ||
})(TupleIndex = exports.TupleIndex || (exports.TupleIndex = {})); | ||
const getUUID = (a, b) => { | ||
@@ -23,3 +28,3 @@ for (b = a = ''; a++ < 36; b += 4 << ~a * 6.5 ? (a ^ 15 ? 8 ^ Math.random() * (a ^ 20 ? 16 : 4) : 4).toString(16) : '-') | ||
if (topicRecord) { | ||
Object.values(topicRecord.subscriptionMap).forEach(publicHook => publicHook[HOOK_PUBLISH_INDEX](newState)); | ||
Object.values(topicRecord.subscriptionMap).forEach(publicHook => publicHook[TupleIndex.Publish](newState)); | ||
topicRecord.currentState = newState; | ||
@@ -26,0 +31,0 @@ topicRecord.hasBeenPublished = true; |
{ | ||
"name": "treble-hook", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"description": "Get hooked on simple subscribe-and-publish in ReactJS.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16466
90