Giter Club home page Giter Club logo

xstate-game-state's People

Contributors

dependabot[bot] avatar dinghino avatar

Watchers

 avatar

Forkers

elhombre87

xstate-game-state's Issues

Figure out how to properly handle actions through machines

Issue is that while axis do more or less one thing and can be easily configured with options and such, actions can do basically anything, especially in a web environment where you can do actions both in a canvas, on the state machines themselves or even on the DOM.

Right now - while in the demo configuration there's 2 actions binded, break and fire - only the break action is working through some typescript hacking whatnot directly inside the processInput machine action. This is obviously a no-go since it enforces you to name the "slow down" action break and it only does what it's in there.

Ideas

Assigned upon interpretation

One idea would be to set up a named action like processActions inside the ControlsMachine (createControlsMachine), called before or after the inputs, but not implementing it, and passing an extra argument to the main factory that extracts that type (following xstate types) to enforce developers to a type safe method to pass there.

Problem with this though is that you may not have access to target of the effects for the actions where you interpret the machine, so that would work for simpler actions.

Just handled

Simpler options is that we map the action inputs (from the ControlsMachine) to the state machine (with velocity and actions) and inside the components we react to those where they are needed. it may become complicated to keep track of everything but it may be a quick and dirty solution for everything that does not require internal context changes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.