Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BackgroundSync - suggestion of improvement #2042

Closed
bligny opened this issue Apr 24, 2019 · 3 comments
Closed

BackgroundSync - suggestion of improvement #2042

bligny opened this issue Apr 24, 2019 · 3 comments

Comments

@bligny
Copy link

bligny commented Apr 24, 2019

Following my recent request to be able to know Queue lengths, a new getAll() method has just been added in version 4.3.0 (cfr #2018).
Very nice...but the fact is that the created Queue object is currently fully private and not exposed at all to the outside world:

class Plugin {
  
  constructor(...queueArgs) {
    this._queue = new Queue(...queueArgs);
  }

In particular, I would like to be able to also access any (public) queue method outside the Plugin (or outside possible queue callbacks/hooks).

Therefore, I'm suggesting the following changes.

  1. Either expose the _queue using a new getQueue() method on Plugin object

  2. Or enrich the Plugin constructor in order to accept

  • [as now] the same arguments as the Queue constructor
  • [new] OR a pre-populated queue object

That is to say something like (sorry, I'm not a js guru):

class Plugin {
  
  constructor(...queueArgs) {
    this( new Queue(...queueArgs) );
  }

  constructor(myqueue: Queue) {
    this._queue = myqueue;
  }

Which would make it possible to have this kind of WB initialisation:

const myQueue =  new workbox.backgroundSync.Queue('my-queue', {
  maxRetentionTime: Infinity
});

const myPlugin = new workbox.backgroundSync.Plugin(myQueue);

workbox.routing.registerRoute(
  new RegExp(...),
  new workbox.strategies.NetworkOnly({
    fetchOptions: {},
    plugins: [myPlugin]
  }),
  'PUT'
);

And then later on, be able to invoke queue methods, e.g. :

// With option 1)
myPlugin.getQueue().getAll().then( (data) => {       
     console.log('The queue still contains', data.length, 'items !');
});  
// With option 2)
myQueue.getAll().then( (data) => {       
     console.log('The queue still contains', data.length, 'items !');
});  
@bligny
Copy link
Author

bligny commented Apr 24, 2019

I've suggested another feature into a separate issue: #2044

@l3d00m
Copy link

l3d00m commented Aug 29, 2022

Hi, is there a status update on this feature request?

Without it, it's not possible to get a list of pending requests. For that it's currently necessary to implement it with Queue directly, which is a lot more work.

@tomayac
Copy link
Member

tomayac commented Apr 25, 2024

Hi there,

Workbox is moving to a new engineering team within Google. As part of this move, we're declaring a partial bug bankruptcy to allow the new team to start fresh. We realize this isn't optimal, but realistically, this is the only way we see it working. For transparency, here're the criteria we applied:

Thanks, and we hope for your understanding!
The Workbox team

@tomayac tomayac closed this as completed Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants