Commit Graph

5 Commits

Author SHA1 Message Date
Alan Norbauer 4aabf4b6b3 Replace jest.resetModuleRegistry() with jest.resetModules()
Reviewed By: cpojer

Differential Revision: D4344961

fbshipit-source-id: 45453ec7ee3211743946ab9156f51430322b5832
2016-12-18 17:13:38 -08:00
Spencer Ahrens 9b184cc0f4 Fix bug in cancelling last task in TaskQueue
Summary:
We don't want to remove the last queue from the stack, it should just have no tasks in it.

Fixes issue reported here: https://www.facebook.com/groups/reactnativeoss/permalink/1569170356712926/

Reviewed By: yungsters

Differential Revision: D3539287

fbshipit-source-id: ea95673491fee0ea82f0f1b79b8f60e00cd3d035
2016-07-11 16:13:49 -07:00
Spencer Ahrens be09cccb1f Make InteractionManager tasks cancellable
Summary:
Returns a promise-like object with a new cancel function that will dig through the queue
and remove relevant tasks before they are executed. Handy when tasks are scheduled in react
components but should be cleaned up in unmount.

Reviewed By: devknoll

Differential Revision: D3406953

fbshipit-source-id: edf1157d831d5d6b63f13ee64cfd1c46843e79fa
2016-06-08 22:58:19 -07:00
Christoph Pojer d363b1f2e2 Update Jest APIs on fbsource
Reviewed By: javache

Differential Revision: D3229435

fb-gh-sync-id: b0e252d69e1f399a946fca6e98ef62ff44c2ef9c
fbshipit-source-id: b0e252d69e1f399a946fca6e98ef62ff44c2ef9c
2016-04-27 19:16:32 -07:00
Spencer Ahrens 893a54d0cd Add yieldy, chained async task support to InteractionManager
Summary:
Default behavior should be unchanged.

If we queue up a bunch of expensive tasks during an interaction, the default
`InteractionManager` behavior would execute them all in one synchronous loop at
the end the JS event loop via one `setImmediate` call, blocking the JS thread
the entire time.

The `setDeadline` addition in this diff enables an option to only execute tasks
until the `eventLoopRunningTime` is hit (added to MessageQueue/BatchedBridge),
allowing the queue execution to be paused if an interaction starts in between
tasks, making the app more responsive.

Additionally, if a task ends up generating a bunch of additional tasks
asynchronously, the previous implementation would execute these new tasks after
already scheduled tasks. This is often fine, but I want it to fully resolve
async tasks and all their dependencies before making progress in the rest of the
queue, so I added support for `type PromiseTask = {gen: () => Promise}` to do
just this. It works by building a stack of queues each time a `PromiseTask` is
started, and pops them off the stack once they are resolved and the queues are
processed.

I also pulled all of the actual queue logic out of `InteractionManager` and into
a new `TaskQueue` class to isolate concerns a bit.

public

Reviewed By: josephsavona

Differential Revision: D2754311

fb-gh-sync-id: bfd6d0c54e6410cb261aa1d2c5024dd91a3959e6
2015-12-23 16:12:30 -08:00