thinkpixellab / PxLoader

PxLoader is a simple JavasScript library for creating preloaders and resource downloaders for HTML5 apps.

Home Page:http://thinkpixellab.com/pxloader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Advice on how to write a plugin for inline or async data operations (e.g. promises)

droplab opened this issue · comments

Hi, have been using this library for years - thanks for the efforts on this. I've been mulling over whether it's possible for a plugin to handle asynchronous/promise operations? A couple of use cases:

  • I'm pulling data asynchronously from a remote api, I want pxloader to wait for the data to come in. I just saw that there is a PxLoaderData plugin for this use case.
  • I'm running internal data handling logic that involves the use of a promise. I want pxloader to wait for the promise to resolve.

I took a quick look at some of the existing plugins but didn't have time to dig into them. I imagine others must have this same use case in their apps. So my question at this point is, what is the best approach here: write a custom plugin that ties all of this into pxloader or handle these types of async/promise operations outside of pxloader?

If it's the latter, the issue is then how to seamlessly integrate into pxloader's progress/complete logic and handlers?

Thanks in advance for any guidance/info on this.

Howdy, I was able to write a plugin for this -- ended up being pretty easy. Let me know if you want me to do a pull request if you think this is useful for anyone else. Cheers