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

ts-bus

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-bus - npm Package Compare versions

Comparing version 0.5.0 to 1.0.0

2

package.json
{
"name": "ts-bus",
"version": "0.5.0",
"version": "1.0.0",
"main": "index.js",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -18,2 +18,3 @@ "use strict";

var react_1 = __importDefault(require("react"));
var react_test_renderer_1 = require("react-test-renderer");
var react_hooks_1 = require("@testing-library/react-hooks");

@@ -113,2 +114,41 @@ var react_2 = require("./react");

});
it("should not loose events during the render cycle when mounted.", function (done) {
var myBus = new EventBus_1.EventBus();
var reducer = jest.fn(function (s) { return s; });
var EVENT_DELAY = { type: "myevent", payload: "DELAY" };
var EVENT_URGENT = { type: "myevent", payload: "URGENT" };
function MyContextProvider(props) {
react_2.useBusReducer({}, reducer);
return props.children;
}
function EventPublisher() {
var b = react_2.useBus();
react_1.default.useEffect(function () {
setTimeout(function () {
b.publish(EVENT_DELAY);
}, 0);
}, [b]);
react_1.default.useEffect(function () {
b.publish(EVENT_URGENT);
}, [b]);
return react_1.default.createElement("div", null);
}
function App() {
return (react_1.default.createElement(react_2.BusProvider, { value: myBus },
react_1.default.createElement(MyContextProvider, null,
react_1.default.createElement(EventPublisher, null))));
}
// render the component
react_hooks_1.act(function () {
react_test_renderer_1.create(react_1.default.createElement(App, null));
});
setTimeout(function () {
var eventList = reducer.mock.calls.map(function (_a) {
var ev = _a[1];
return ev;
});
expect(eventList).toEqual([EVENT_URGENT, EVENT_DELAY]);
done();
}, 0);
});
//# sourceMappingURL=react.test.js.map

@@ -15,4 +15,4 @@ "use strict";

var _a = react_1.useReducer(reducer, initState), state = _a[0], dispatch = _a[1];
// Run the subscriber
react_1.useEffect(function () { return subscriber(dispatch, bus); }, [subscriber, dispatch, bus]);
// Run the subscriber synchronously
react_1.useLayoutEffect(function () { return subscriber(dispatch, bus); }, [subscriber, dispatch, bus]);
return state;

@@ -19,0 +19,0 @@ }

Sorry, the diff of this file is not supported yet

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