lizadaly/windrift

Client-moved trigger is causing an infinite loop

lizadaly opened this issue · 2 comments

When the snake sets off the alarm in the bar, it's causing an infinite loop—

The raccoon client detects a change in the choice Redux store, firing a Pusher event which then clears the API cache. As a result for both players the story state seems to flip-flop between alarm-triggered, not alarm-triggered. Maybe there's a race condition happening between the time when the remote state is updated? Probably introduced by https://github.com/lizadaly/windrift/pull/283/files?

I think it should be filtering on only local changes, not propagated ones.

As written this is fragile, it would be better if it were directly triggered imperatively as part of makeChoice, but that's not available as a hook.

Maybe a separate reducer that is just a simple incrementing counter?