@bloc-js/react-bloc
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -1,2 +0,2 @@ | ||
import { Component, ReactNode } from "react"; | ||
import { ReactNode } from "react"; | ||
import { Bloc } from "@bloc-js/bloc"; | ||
@@ -10,8 +10,2 @@ export interface IBlocBuilderProps<S> { | ||
} | ||
export declare class BlocBuilder<S> extends Component<IBlocBuilderProps<S>, IBlocBuilderState<S>> { | ||
constructor(props: IBlocBuilderProps<S>); | ||
private subscription; | ||
componentDidMount(): void; | ||
componentWillUnmount(): void; | ||
render(): ReactNode; | ||
} | ||
export declare function BlocBuilder<S>(props: IBlocBuilderProps<S>): ReactNode; |
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var react_1 = require("react"); | ||
var rxjs_1 = require("rxjs"); | ||
var BlocBuilder = (function (_super) { | ||
__extends(BlocBuilder, _super); | ||
function BlocBuilder(props) { | ||
var _this = _super.call(this, props) || this; | ||
_this.state = { data: _this.props.bloc.currentState }; | ||
_this.subscription = rxjs_1.Subscription.EMPTY; | ||
return _this; | ||
} | ||
BlocBuilder.prototype.componentDidMount = function () { | ||
var _this = this; | ||
this.subscription = this.props.bloc.state$.subscribe(function (data) { | ||
_this.setState({ data: data }); | ||
function BlocBuilder(props) { | ||
var _a = react_1.useState(props.bloc.currentState), state = _a[0], setState = _a[1]; | ||
react_1.useEffect(function () { | ||
var subscription = props.bloc.state$.subscribe(function (data) { | ||
setState(data); | ||
}); | ||
}; | ||
BlocBuilder.prototype.componentWillUnmount = function () { | ||
this.subscription.unsubscribe(); | ||
}; | ||
BlocBuilder.prototype.render = function () { | ||
return this.props.builder(this.state.data); | ||
}; | ||
return BlocBuilder; | ||
}(react_1.Component)); | ||
return function () { return subscription.unsubscribe(); }; | ||
}); | ||
return props.builder(state); | ||
} | ||
exports.BlocBuilder = BlocBuilder; | ||
//# sourceMappingURL=bloc-builder.js.map |
{ | ||
"name": "@bloc-js/react-bloc", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "React components for implementing the BLoC pattern.", | ||
@@ -39,6 +39,3 @@ "keywords": [ | ||
}, | ||
"dependencies": { | ||
"rxjs": "^6.5.2" | ||
}, | ||
"gitHead": "9e8a946bb9cfad74c9aa573d2a3d347713b4ef69" | ||
"gitHead": "64bf6dda3d6fe97f594450ac12c434e8d4c77e0d" | ||
} |
Sorry, the diff of this file is not supported yet
2
2820
31
- Removedrxjs@^6.5.2