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

react-game-engine

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-game-engine - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

10

build/index.js

@@ -305,10 +305,10 @@ module.exports =

_this.defer = function (e) {
setTimeout(function () {
return _this.dispatch(e);
}, 0);
_this.dispatch(e);
};
_this.dispatch = function (e) {
_this.events.push(e);
if (_this.props.onEvent) _this.props.onEvent(e);
setTimeout(function () {
_this.events.push(e);
if (_this.props.onEvent) _this.props.onEvent(e);
}, 0);
};

@@ -315,0 +315,0 @@

{
"name": "react-game-engine",
"version": "0.1.1",
"version": "0.2.0",
"description": "A lightweight game engine for React projects",

@@ -5,0 +5,0 @@ "main": "build/index.js",

@@ -41,30 +41,2 @@ <p align="center">

### Dispatch vs Defer
The other `args` into the systems are still there. Hoever, there is one confusing change which I'm a bit dubious about at this moment.
In RNGE, each system is passed a `dispatch` function that will send out an event asynchronously (once the frame is complete). This function has now been replaced by `defer` - deferring the processing of an event once the frame completes.
`dispatch` is still there, however this will send out the event synchronously - causing any event handlers to be fired immediately.
```javascript
const sys1 = (entities, { input, defer, dispatch }) => {
const { payload } = input.find(x => x.name === "onMouseDown");
if (payload) {
dispatch("mouse-clicked"); //-- Event handlers will be notified immediately, blocking execution of the current frame
defer("mouse-clicked"); //-- Event handlers will be notified once this frame is completed
}
return entities;
};
````
Like I said, I'm dubious about this change - happy to hear any feedback on this..
## Table of Contents

@@ -208,4 +180,3 @@

|**`swap`**|A method that can be called to update your game with new entities. Can be useful for level switching etc. You can also pass a Promise that resolves to an entities object into this method. |`{} or Promise`|
|**`dispatch`**|A method that can be called to dispatch events right now. The event will be received by the **subsequent** systems and any `onEvent` callbacks |`event`|
|**`defer`**|A method that can be called to fire events after the currenty frame completed. The event will be received by **ALL** the systems and any `onEvent` callbacks |`event`|
|**`dispatch`**|A method that can be called to fire events after the currenty frame completed. The event will be received by **ALL** the systems and any `onEvent` callbacks |`event`|

@@ -212,0 +183,0 @@ ## FAQ

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