Code Monkey home page Code Monkey logo

javascript-state-machine's People

Contributors

akimotorakiyu avatar cbaatz avatar cboone avatar conorgil avatar demisx avatar ifdattic avatar imeditron avatar jakesgordon avatar offirmo avatar quentinroy avatar taoqf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

javascript-state-machine's Issues

GOTO - Changing State Without a Transition --> not working with factory

Can anyone help me with that:

var FSM = StateMachine.factory({
  init: 'A',
  transitions: [{
    name: 'step',
    from: 'A',
    to: 'B'
  }, {
    name: 'step',
    from: 'B',
    to: 'C'
  }]
});

var fsm1 = new FSM();
fsm1.goto('B');

I'm getting the following error:
fsm1.goto('B');
^
TypeError: fsm1.goto is not a function

$ node -v
$ v8.2.0

OnBeforeTransition - promise returning false doesn't cancel state transition

According to the docs, the following behavior is incorrect: when the onBeforeTransition function returns a Promise which resolves with false, I would expect that the state transition fails. However that's not the case, it continues and calls onEnterState.

What I noticed is that:
a. If the onBeforeTransition method is sync and returns false synchronously, then it behaves as expected and the state transition is canceled.
b. If the onBeforeTransition method is async and returns a rejected promise, then it also behaves as expected and the state transition is canceled.

Are the docs incorrect maybe? Or is it a bug?

ReferenceError: dist is not defined

Something looks bad in the minified script which is the entry point of the lib.

image

I'm using
"react-app-rewired": "^1.5.2",
"react-scripts-ts": "^2.17.0",
webpack "3.8.1"

The problem occures with dev server and production build as well. Do you have any idea what's wrong?
I suspect that setting the main to "dist/state-machine.min.js" might not be a good idea, the original lib has "lib/state-machine.js". Perhaps the double uglification causes a mess. What do you think?

Typescript Definition files error

Hi. I've installed this module under existing TypeScript project, because the upstream one still doesn't have v3 type definitions as far as I understand. However, the types/state-machine.d.ts is throwing a bunch of errors in my VSCode IDE (see attached). Am I missing anything?

screen shot 2018-08-02 at 9 28 32 am

TS 定义中,没有 state 属性的定义吗?

declare class StateMachine {
	constructor(options: Partial<StateMachine.Options>);
	static factory(options: Partial<StateMachine.Options>): StateMachine.IFSM;
	static factory<T>(instance: T, options: Partial<StateMachine.Options>): StateMachine.IFSM | T;
	[action: string]: ((...args: any[]) => any);
	is: StateMachine.StateMachineIs;
	can: StateMachine.StateMachineCan;
	cannot: StateMachine.StateMachineCan;
	transitions: StateMachine.StateMachineTransitions;
	allTransitions: StateMachine.StateMachineTransitions;
	allStates: StateMachine.StateMachineStates;
	observe: StateMachine.Observe;
	// history: string[];
	clearHistory(): void;
	historyBack(): void;
	historyForward(): void;
	canHistory(): boolean;
	canhistoryForward(): boolean;
}

我扩展了这个状态机类,但是需要用到 state 属性,在 js 中是有的,但是TS中没有定义,可以添加一个吗?

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.