Skip to content

Time driven loop #22

@sfrdmn

Description

@sfrdmn

Currently main-loop diffs and renders views as needed, when the state is changed. This works great for state which is a function of user input, but seemingly not as well for state which is a function of the render loop itself, i.e. time. I'm thinking of a momentum scroller, for example, whose state is still changing after the user has removed all inputs.

I'm wondering whether you think it's in the scope of this module to handle the case where the application needs a more game-loop like model. Of course, this could be achieved with a second loop, but this doesn't seem quite right - at least for the fact that changing state in the one animation frame will schedule a rerender for the next frame, whereas you really want to update it immediately.

Maybe there could be an option to provide an 'ontick' hook, in which case there is a continual raf callback at work, which checks a 'dirty' flag if it needs to rerender. If there is no hook, it can function the same as it does now and schedule the raf callback as needed

Maybe the loop logic could be reused from another node module?

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