Skip to content

Explicitly know it's an undo action? #162

@sidonaldson

Description

@sidonaldson

I have an interesting problem and I would love some thoughts on the best solution.

I have a map instance which has a moveend listener. After the user moves the map I trigger an action called mapMoved which stores the center and zoom etc.
To prevent the map from trying to move again on componentWillReceiveProps (because I've just moved it manually) I look for the original mouseevent to know it's human interaction and add the property human:true.

Now, when I try to undo the action it works as expected except the human flag is still present.
Is it an anti-pattern to suggests an optional property which flags the fact it's an undo action... e.g

{
    present:{},
    past:[],
   future:[],
   undid: true
}

Alternatively I could add some logic to stop the map moving if mapOptions.future.length === 0 (this is the simplest solution), or add logic to mapStateToProps to check the map isn't in the final position already (least ideal).

Thanks!

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