Skip to content

Commit

Permalink
Merge pull request #286 from fatcerberus/sphere-dispatch-now
Browse files Browse the repository at this point in the history
Add support for Sphere Dispatch API
  • Loading branch information
zloirock authored Apr 5, 2017
2 parents bbd5511 + 141a8e9 commit f3ed642
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions modules/_task.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var ctx = require('./_ctx')
, setTask = global.setImmediate
, clearTask = global.clearImmediate
, MessageChannel = global.MessageChannel
, Dispatch = global.Dispatch
, counter = 0
, queue = {}
, ONREADYSTATECHANGE = 'onreadystatechange'
Expand Down Expand Up @@ -41,6 +42,11 @@ if(!setTask || !clearTask){
defer = function(id){
process.nextTick(ctx(run, id, 1));
};
// Sphere (JS game engine) Dispatch API
} else if(Dispatch && Dispatch.now){
defer = function(id){
Dispatch.now(ctx(run, id, 1));
};
// Browsers with MessageChannel, includes WebWorkers
} else if(MessageChannel){
channel = new MessageChannel;
Expand Down

0 comments on commit f3ed642

Please sign in to comment.