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 2.0.0-alpha.2 to 2.0.0-alpha.3

2

lib/index.d.ts
import React, { Dispatch, SetStateAction } from 'react';
declare const _default: {
addTopic<T>(topicName: string, defaultValue: T): void;
getPublisher(): React.FunctionComponent<{
getPublisher(topics?: string[] | undefined): React.FunctionComponent<{
children?: React.ReactNode;

@@ -6,0 +6,0 @@ }>;

@@ -11,7 +11,7 @@ "use strict";

const react_1 = __importStar(require("react"));
const topics = {};
const topicsCache = {};
exports.default = (function TrebleHookPublisherFactory() {
return {
addTopic(topicName, defaultValue) {
if (topics[topicName]) {
if (topicsCache[topicName]) {
throw new Error(`The topic "${topicName}" has already been added.`);

@@ -21,3 +21,3 @@ }

const provider = createPublishProvider(context, defaultValue);
topics[topicName] = {
topicsCache[topicName] = {
context,

@@ -27,6 +27,9 @@ provider,

},
getPublisher() {
getPublisher(topics) {
const TrebleHookPublisher = ({ children, }) => {
const ProviderNest = Object.keys(topics).reduce((tally, topicName) => {
const topic = topics[topicName];
const topicNames = topics && topics.length
? Object.keys(topicsCache).filter(key => topics.some(topicName => topicName === key))
: Object.keys(topicsCache);
const ProviderNest = topicNames.reduce((tally, topicName) => {
const topic = topicsCache[topicName];
if (!topic) {

@@ -45,6 +48,6 @@ throw new Error(getNoTopicErrorMessage(topicName));

function usePubSub(topic) {
if (!topics[topic]) {
if (!topicsCache[topic]) {
throw new Error(getNoTopicErrorMessage(topic));
}
const topicDef = topics[topic];
const topicDef = topicsCache[topic];
const context = react_1.useContext(topicDef.context);

@@ -51,0 +54,0 @@ if (!context) {

{
"name": "treble-hook",
"version": "2.0.0-alpha.2",
"version": "2.0.0-alpha.3",
"description": "Get hooked on simple subscribe-and-publish in ReactJS.",

@@ -24,2 +24,3 @@ "main": "./lib/index.js",

"lint": "tslint -c ./tslint.json ./src/**/*.tsx",
"publishNext": "yarn publish --tag next",
"prepublishOnly": "yarn test",

@@ -26,0 +27,0 @@ "pretest": "yarn build",

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