Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

treble-hook

Package Overview
Dependencies
Maintainers
6
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

treble-hook - npm Package Compare versions

Comparing version 0.0.27 to 0.0.28

17

lib/index.d.ts

@@ -0,1 +1,7 @@

/*!*
* Copyright (c) Igneous, Inc. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
export declare enum PubSubTupleIndex {

@@ -7,2 +13,13 @@ State = 0,

export declare type Publish<T> = (newState: T) => void;
export interface TrebleHookConfig {
suppressDupeStateWarning?: boolean;
topicConfig?: TopicConfigMap;
}
export interface TopicConfig {
allowDupeState?: boolean;
}
export interface TopicConfigMap {
[topic: string]: TopicConfig;
}
export declare function configPubSub(config: TrebleHookConfig): void;
export declare function usePubSub<T>(topic: string, defaultState: T): SubscriptionTuple<T>;

@@ -9,0 +26,0 @@ declare type PublicUnsubscribe = () => void;

21

lib/index.js
"use strict";
/*!*
* Copyright (c) Igneous, Inc. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Object.defineProperty(exports, "__esModule", { value: true });

@@ -15,2 +21,3 @@ const react_1 = require("react");

};
let trebleHookConfig = {};
const topics = {};

@@ -29,4 +36,5 @@ const getCurrentState = (topic) => {

if (topicRecord) {
const allowDupeState = false;
const suppressDupeStateWarning = false;
const allowDupeState = trebleHookConfig.topicConfig
&& trebleHookConfig.topicConfig[topic]
&& trebleHookConfig.topicConfig[topic].allowDupeState;
let proceed = true;

@@ -43,4 +51,5 @@ if (!allowDupeState) {

}
else if (!suppressDupeStateWarning) {
console.warn('[treble-hook] A publish of unchanged state was attempted for topic:', topic, '\n\n\t- If this is desired behavior then set the "allowDupeState" flag to true', '\n\t-To suppress this warning, set either "allowDupeState" or "suppressDupeStateWarning" flag to true');
else if (!trebleHookConfig.suppressDupeStateWarning) {
console.warn('[treble-hook] A publish of unchanged state was attempted for topic:', topic, '\n\n\t- If this is desired behavior then set the "allowDupeState" flag to true', '\n\t-To suppress this warning, set either "allowDupeState" for topic to true ' +
'or set the global "suppressDupeStateWarning" flag to true');
}

@@ -58,2 +67,6 @@ }

};
function configPubSub(config) {
trebleHookConfig = { ...trebleHookConfig, ...config };
}
exports.configPubSub = configPubSub;
function usePubSub(topic, defaultState) {

@@ -60,0 +73,0 @@ if (arguments.length !== 2) {

2

package.json
{
"name": "treble-hook",
"version": "0.0.27",
"version": "0.0.28",
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc