You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@player-ui/react-subscribe

Package Overview
Dependencies
Maintainers
2
Versions
461
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@player-ui/react-subscribe - npm Package Compare versions

Comparing version

to
0.11.3--canary.666.24188

src/index.test.tsx

43

dist/index.legacy-esm.js
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/react/subscribe/src/index.tsx
import React from "react";
import { useSyncExternalStore } from "use-sync-external-store/shim";
function deferred() {

@@ -99,16 +100,32 @@ let resolve = () => void 0;

function useSubscribedState(subscriber) {
const [state, setState] = React.useState(subscriber.get());
React.useEffect(() => {
const id = subscriber.add(
(resp) => {
setState(resp);
},
{
initializeWithPreviousValue: true
}
);
return () => {
subscriber.remove(id);
};
const subscription = React.useMemo(() => {
function subscribe(callback) {
const id = subscriber.add(
(resp) => {
callback(resp);
},
{
initializeWithPreviousValue: true
}
);
return () => {
if (subscriber) {
subscriber.remove(id);
}
};
}
return subscribe;
}, [subscriber]);
function getSnapshot() {
try {
return subscriber.get();
} catch (err) {
return void 0;
}
}
const state = useSyncExternalStore(
subscription,
getSnapshot,
() => void 0
);
return state;

@@ -115,0 +132,0 @@ }

@@ -9,3 +9,3 @@ {

"name": "@player-ui/react-subscribe",
"version": "0.11.3--canary.666.24070",
"version": "0.11.3--canary.666.24188",
"main": "dist/cjs/index.cjs",

@@ -25,2 +25,3 @@ "module": "dist/index.legacy-esm.js",

"p-defer": "^3.0.0",
"use-sync-external-store": "^1.5.0",
"tslib": "^2.6.2"

@@ -30,4 +31,5 @@ },

"@types/react": "^18.2.39",
"@types/use-sync-external-store": "^1.5.0",
"react": "^18.2.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet