SkaterDad/cycle-snabbdom-examples

HTTP requests go crazy when re-entering that example

Closed this issue · 1 comments

The project currently contains two example apps, which are implemented as nested dialogues. You can toggle between them, similar to how the routes are toggle in cycle-starter.

The following steps produce a nasty bug (open the browser network monitor in dev tools):

  1. Go to the Github search example and do a couple searches. You should see one request being sent per search, possibly some canceled requests depending on how fast you type (it has a 500ms delay).
  2. Switch back to the Color Changer example.
  3. Go back to the Github search example. Bug #1 is that this page fires off a request right away (duplicate of the last one you did before leaving the page, this issue will be fixed later). Bug #2 is that new searches will fire off 4 times at once. Github's API server doesn't like it, so tread carefully to avoid errors.
  4. If you repeat this process, you'll end up with the searches firing off 8 at once.

Is anyone able to shed some light on this? I am new to Rx and Cycle, so I feel like I'm missing something fundamental.

I put some .do(x => console.log('DOM/HTTP event fired.')) operators on the DOM and HTTP request streams which are returned by main() for some extra info.

Looks like the DOM events are firing up multiple times as well. Oddly enough, it looks like the # of DOM events = # HTTP events squared.