css-element-queries icon indicating copy to clipboard operation
css-element-queries copied to clipboard

Custom Scheduler

Open pzuraq opened this issue 7 years ago • 2 comments
trafficstars

This library has been awesome for us, but we're having some trouble integrating it into our JS framework. We use Ember.js, and most work in Ember is scheduled using some kind of global scheduler. Importantly, the schedulers integrate with our test suites to ensure that all work has been completed before the test completes.

Would it be possible to add an option to substitute a custom requestAnimationFrame function (essentially a wrapper function) for scheduling updates?

pzuraq avatar Apr 13 '18 16:04 pzuraq

I'm not sure I understand: This library is listening on a resize event and modifies some html attributes so your used css-selectors are applied. Where exactly do you need intervention?

marcj avatar Apr 13 '18 17:04 marcj

Right here:

https://github.com/marcj/css-element-queries/blob/master/src/ResizeSensor.js#L223

We put all of our usage of requestAnimationFrame app-wide into this scheduler: https://github.com/html-next/ember-raf-scheduler and watch for items being pushed into it during tests to make sure the entire RAF queue has been flushed. We also use it for things like debouncing, but it seems like you've already done that internally with the EventQueue so that's definitely helpful!

pzuraq avatar Apr 13 '18 17:04 pzuraq