Skip to content

Immutable state is problematic in async nodes like Delay #230

@bhouston

Description

@bhouston

The immutable state pattern is problematic in nodes like delay.

the problem is this:

  • Delay is triggered and it will check its "pending" state and if it is false, it will set its pending state to true and return that. Otherwise it will return immediately.
  • Delay will then use an setTimeout to get execution back outside of the behave-graph system and then trigger its flow node. This happens outside of behave-graph trigging the node again, thus it doesn't get a state to operate on and it also can not return a state using the current design.

In order to get around this I could add these functions:

  • getState() which will return the current state of a node.
  • setState() which will set the current state of a node.

Then delay node could use this to modify it state outside of the standard execution flow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions