New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@bloc-js/react-bloc

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bloc-js/react-bloc - npm Package Compare versions

Comparing version

to
1.2.18

3

lib-es/use-bloc-state.d.ts
import { Bloc } from "@bloc-js/bloc";
export declare function useBlocState<S>(bloc: Bloc<any, S>): S;
export declare type CreateBlocFn<S> = () => Bloc<any, S>;
export declare function useBlocState<S>(bloc: Bloc<any, S> | CreateBlocFn<S>): S | undefined;
import { useEffect, useState } from "react";
export function useBlocState(bloc) {
var _a = useState(bloc.currentState), state = _a[0], setState = _a[1];
var _a = useState(), state = _a[0], setState = _a[1];
useEffect(function () {
var subscription = bloc.state$.subscribe(function (nextState) {
var actualBloc = typeof bloc === "function" ? bloc() : bloc;
setState(actualBloc.currentState);
var subscription = actualBloc.state$.subscribe(function (nextState) {
setState(nextState);
});
return function () { return subscription.unsubscribe(); };
});
}, []);
return state;
}
//# sourceMappingURL=use-bloc-state.js.map
import { Bloc } from "@bloc-js/bloc";
export declare function useBlocState<S>(bloc: Bloc<any, S>): S;
export declare type CreateBlocFn<S> = () => Bloc<any, S>;
export declare function useBlocState<S>(bloc: Bloc<any, S> | CreateBlocFn<S>): S | undefined;
import { useEffect, useState } from "react";
export function useBlocState(bloc) {
const [state, setState] = useState(bloc.currentState);
const [state, setState] = useState();
useEffect(() => {
const subscription = bloc.state$.subscribe(nextState => {
const actualBloc = typeof bloc === "function" ? bloc() : bloc;
setState(actualBloc.currentState);
const subscription = actualBloc.state$.subscribe(nextState => {
setState(nextState);
});
return () => subscription.unsubscribe();
});
}, []);
return state;
}
//# sourceMappingURL=use-bloc-state.js.map
import { Bloc } from "@bloc-js/bloc";
export declare function useBlocState<S>(bloc: Bloc<any, S>): S;
export declare type CreateBlocFn<S> = () => Bloc<any, S>;
export declare function useBlocState<S>(bloc: Bloc<any, S> | CreateBlocFn<S>): S | undefined;

@@ -5,9 +5,11 @@ "use strict";

function useBlocState(bloc) {
var _a = react_1.useState(bloc.currentState), state = _a[0], setState = _a[1];
var _a = react_1.useState(), state = _a[0], setState = _a[1];
react_1.useEffect(function () {
var subscription = bloc.state$.subscribe(function (nextState) {
var actualBloc = typeof bloc === "function" ? bloc() : bloc;
setState(actualBloc.currentState);
var subscription = actualBloc.state$.subscribe(function (nextState) {
setState(nextState);
});
return function () { return subscription.unsubscribe(); };
});
}, []);
return state;

@@ -14,0 +16,0 @@ }

{
"name": "@bloc-js/react-bloc",
"version": "1.2.17",
"version": "1.2.18",
"description": "React components for implementing the BLoC pattern.",

@@ -47,3 +47,3 @@ "keywords": [

},
"gitHead": "f5dd68795f715516e9787630cb8b35b470a92a6f"
"gitHead": "672226bcf8d9441652523c6fed641f7b67775281"
}

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