Git Product home page Git Product logo

stated's People

Contributors

jordanhamill avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

stated's Issues

Specifying a method as sideEffect creates a retain cycle

All of the side effects in the example code from the README create a retain cycle that keeps instances of AppLauncher alive indefinitely.

The problem is that when taking a reference to a method, it implicitly takes a strong reference on self.

The sideEffect is stored here:

public let sideEffect: (StateMachine, StateTo, StateFrom, SentInput<Arguments>) -> Void

The only way I know to migitate this is to always wrap methods in a closure with [weak self] when using them as side effect.

Add way to specify all inputs or all states

Nice library! This made my state machines more sane!

It would be useful if you could specify a transition that is triggered for all inputs when in a certain state and transitions that get triggered from any state given a specific input.

This could be done using a special input like anyInput() and A special AnyState.

Like this:

anyInput() | States.someState => States.someOtherState | sideEffect,
Inputs.error() | AnyState.slot => States.errorState | handleError,

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.