Giter Club home page Giter Club logo

meteor-subs-cache's Introduction

Meteor Subscription Cache

This package is similar to meteorhacks:subs-manager. The goal is to cache subscriptions.

Suppose you are subscribing to a post:

sub = Meteor.subscribe('post', postId)

When the user clicks to another page, you typically want to stop the subscription

subs.stop()

This will clean up and throw away the data you don't need. But what if the user clicks back immediately after you stopped the subscription? Now you have resubscribe to the same data. This is a waste. SubsCache allows you to cache your subscriptions. When you stop a SubCache subscription, it will start a setTimeout and stop the subscription after expireAfter minutes. If you resubscribe to the same subscription before the cached subscription expired, then the setTimeout is cleared and the subscription is restored.

meteorhacks:subs-manager comparison

  1. SubsManager will stop your subscription "expireIn" minutes after your subscribe. SubsCache will stop your subscription "expireAfter" minutes after you stop (or the current reative computation stops).
  1. SubsManager does not have a ready function for each subscription. subsManager.ready tells you if all cached subscriptions are ready. SubsCache as subsCache.allReady() and individual sub.ready()

  2. SubsManager does not allow you to have subscriptions with different expiration times in the same cache. SubsCache allows you set the default expireAfter upon initialization but you can use subscribeFor(expireAfter, ...) to subscribe and cache for a different time.

  3. SubsManager does not allow infinite items in a cache. SubsCache does if you set cacheLimit to -1.

  1. SubsManager does not allow subscriptions that never expire. SubsCache does if you set expireAfter to -1.

Getting Started

meteor add ccorcos:subs-cache

Initialize with optional expireAfter (default 5) and cacheLimit (default 10). expireAfter is the number of minutes after a subscription is stopped without having been restarted before truely stopping it. If set to -1, the subscription will never expire. cacheLimit is the max number of subscriptions to cache. Set to -1 for unlimited capacity.

    subsCache = new SubsCache(5, 10);
    // first argument is expireAter -- default is 5 minutes
    // second argument is cacheLimit -- default is 10
  • sub = subsCache.subscribe(...) creates a subscription just like Meteor.subscribe

  • sub = subsCache.subscribeFor(expireIn, ...) allow you to set the expiration other than the defualt.

  • subsCache.clear() will stop all subscription immediately

  • subsCache.ready() tells you if all subscriptions in the cache are ready

  • subsCache.onReady(func) will call a function once all subscription are ready

  • sub.stop() will cache a subscription and stop after expireAfter unless restarted with sub.restart()

  • sub.stopNow() will stop a subscription immediately and remove it from the cache.

  • sub.ready() tells you if an individual subscription is ready

  • sub.onReady(func) will call a function once an individual subscription is ready

Testing

You can run the mocha-based tests in watch mode via:

meteor test-packages ./ --driver-package=cultofcoders:mocha

Known Issues

No data is injected when using with Fast Render

When using the Fast Render package the parameters passed to the subscription must the identical on both Fast Render and Subscache or no data will be injected.

meteor-subs-cache's People

Contributors

budgieinwa avatar ccorcos avatar copleykj avatar gregory avatar gsovereignty avatar icereed avatar janat08 avatar jankapunkt avatar lmachens avatar paranoico avatar ramezrafla avatar sakulstra avatar sbalmer avatar ulion avatar veered avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

meteor-subs-cache's Issues

subscriptionId params are always passed

this
SubsCache.subscribe 'posts'

gets passed to the publication like this:
{ subscriptionId: '4FHxbDWHRdFufDi2e' }

my publication handles different params
Meteor.reactivePublish "posts", (orgId, limit, starredOnly, collectionId) -> ...

but in this case I don't set any params for the subscription. Yet, subsCache adds params which are being passed.
orgId { subscriptionId: '4FHxbDWHRdFufDi2e' }

expireAfter not being set from constructor

When doing this:

subs = new SubsCache({
    expireAter: -1,
    cacheLimit: -1
});

The result is
SubsCache {expireAfter: 5, cacheLimit: -1, cache: Object, allReady: ReactiveVar}

And this needs to be done to set expireAfter to -1:
subs.expireAfter = -1;

I think this is incorrect behaviour.

When cacheLimit is hit, the data gets wiped away

subsMgt = new SubsCache({
  expireAter: 5,  // minutes
  cacheLimit: 10
});

// Inside `autorun` inside `onCreated` callbacks
this.autorun(function () {
    var listId = FlowRouter.getParam('_id');
    if (listId) {
      self.listSub = subsMgt.subscribe('list', listId);
    }
  });

// Here's another
this.autorun(function () {
    if (Session.equals('listIsLoaded', true)) {
      var listItem = getListItem();
      if (listItem && listItem.someField) {
        self.listItemSub = subsMgt.subscribe('otherStuff', listIem.someField);
      }
    }
  });

If I change the cacheLimit to 1, the page will show the data and then the data will disappear because when I go to the list route, it will subscribe to the list, and find the last recently visited list item and go to it and subscribe to that, and once that happens, cache limit is hit and the data gets wiped for some odd reason.

Workaround right now is to set cacheLimit to -1 and manually stopping previous subscriptions.

`allReady` does not work.

With subs-cache 0.1.0 and meteor 1.2 or 1.3, it appears that the allReady reactive variable is not successfully set when subscriptions become ready.

screen shot 2016-06-07 at 12 25 45 am

Overloading Meteor.subscribe

An idea that was inspired by redis-oplog, why not have a parameter that allows us to keep using Meteor.subscribe and it gets redirected to meteor-subs-cache. This would make it BW compatible and easy to bolt on for all users. Maybe have SubsCache.origSubscribe to refer to the old one if needed.

Add CI service

The tests are already running and I added a .travis file a while ago. It would be great to include a CI service like Travis in order to get automatic builds on new pull requests so it is clear to everyone if a new PR passes the tests or not.

end of subscription rerenders current page

First, I want to say that I love this package and use it all my projects. Combined with PublishComposite, it has made a significant improvement to the performance of my projects.

But I noticed today that whenever any subs-cache subscription expires, the current template gets rerendered.

In my case, after a template is rendered, I do a scroll to top, and call an unveil function. I noticed after visiting several paths, then waiting for a backlog of subs-cache subscriptions to expire, that my current page was rescrolled to the top as each subs-cache expired.

I am wondering why the current template is rerendered, as presumably it already has all the data it needs from its own template subscriptions.

Is there a way to disable the rerenders triggered by the subs-cache subscription expiries? Or, perhaps can you suggest a way I can detect that the template has already been previously rendered and i can bypass my scroll-to-top function?

Thanks

Doesn't seem to work for subscription params?

Hi, great package. But it seems it can't handle subscription params? Because when I do something like this:

SubsCache.subscribe 'singlePost', id

it will return the same subscription from cache even when id changes.

Using with fast render within flow-router breaks

I tried several ways to pass subsmanager.subscribe to this.register, and it broke.

var subs = new SubsCache(5, 15)
var subscribe = subs.subscribe
FlowRouter.route('/', {
  name: 'BLOCKRAZOR',
  subscriptions: function () {
    this.register('approvedcurrencies',subscribe("approvedCurrencies");
  },
  action() {
    BlazeLayout.render('desktop', {
      main: 'returnedCurrencies',
      left: 'menu'
    });
  }
})

Passing invoking subs.subscribe within this.register also broke.
this is the error message on client with fast render reporting same issue on server:

TypeError: Cannot read property 'apply' of undefined
    at SubsCache.subscribe (SubsCache.js:85)
    at Route.subscriptions [as _subscriptions] (routes.js:57)
    at Route.callSubscriptions (staringatlights_flow-router.js?hash=54561903308af27a237544b4c13ed49f3776b07e:896)
    at staringatlights_flow-router.js?hash=54561903308af27a237544b4c13ed49f3776b07e:597
    at Tracker.Computation._compute (tracker.js?hash=997515fa2d5b0530ba07741da556c4b36963ef3b:339)
    at Tracker.Computation._recompute (tracker.js?hash=997515fa2d5b0530ba07741da556c4b36963ef3b:358)
    at Object.Tracker._runFlush (tracker.js?hash=997515fa2d5b0530ba07741da556c4b36963ef3b:532)
    at Object.Tracker.flush (tracker.js?hash=997515fa2d5b0530ba07741da556c4b36963ef3b:483)
    at Router._invalidateTracker (staringatlights_flow-router.js?hash=54561903308af27a237544b4c13ed49f3776b07e:659)
    at afterAllTriggersRan (staringatlights_flow-router.js?hash=54561903308af27a237544b4c13ed49f3776b07e:271)

Mongo is not defined

After adding the package to my project, the server crashes with the following error:

W20161215-20:21:24.603(1)? (STDERR) ReferenceError: Mongo is not defined
W20161215-20:21:24.603(1)? (STDERR)     at packages/ccorcos_subs-cache.js:288:18
W20161215-20:21:24.603(1)? (STDERR)     at packages/ccorcos_subs-cache.js:292:4
W20161215-20:21:24.603(1)? (STDERR)     at packages/ccorcos_subs-cache.js:351:3

Update subscription parameters

Hi there!

Has anyone figured out a way to change a subscription parameters after a first init? Like working with pagination. For now, I'm overriding the subscription object in each autorun, causing templates to keep reference to previous object (that's how I understand the issue though) and not updating when the new subscription is created.

My workaround is to create a reactiveVar 'ready' that I set to false every time I update parameters, and set to true in a sub.onReady() callback. Not very complicated, but I'd prefer a more clean way to manage it.

Didn't find anything in docs, issues or in source code. Thanks :)

Error: Can't set timers inside simulations

Callstack:

Error: Can't set timers inside simulations
    at withoutInvocation (timers.js:5)
    at bindAndCatch (timers.js:13)
    at Object._.extend.setTimeout (timers.js:29)
    at Object.SubsCache.SubsCache.subscribeFor.cachedSub.delayedStop (subsCache.coffee:89)
    at subsCache.coffee:85
    at tracker.js:263
    at Object.Tracker.nonreactive (tracker.js:560)
    at Tracker.Computation.invalidate (tracker.js:262)
    at Tracker.Computation.stop (tracker.js:279)
    at null.<anonymous> (view.js:203)

Incompatible with Meteor 1.3 modules

Hi there,

I am enjoying the subs cache package very much enabling me to speed up my app and reducing server load.

Problem

However, while updating my app to Meteor 1.3 modules I encountered, that this package has no export declaration in the package.js. So this package is not usable as a module.

Potential solution

Just add following statement to package.js:
api.export("SubsCache");

I'll create a pull request for that one...

Regards,
Icereed

remove underscore dependency

this is by far not the last package which relies on underscore, but it's definitely not really necessary here ๐Ÿ”

I'll create a pr after the formatting one is merged ;)

Use in mobile apps, with throteling network

Hi @ccorcos, I'm thinking of using your package in a mobile app (meteor-cordova app), already in pre-production.

I had 2 main problems to solve in this app:

  • Treat static, potentially big collections outside of meteor livedata package (no pub/sub): got this with the DumbCollections package;
  • Try to reuse subscriptions between offline/online transitions, even when the browser refreshes. This is to avoid the overhead caused by reloading all data associated to subscribed collections on an offline/online transition (my users may be in zones with a poor network coverage, experiencing many reloads in a short intervals of time)

This last issue is giving me some work. It's a hard problem to solve. I though I could hold on to the subscription handle, save it in local storage and then find a way to reuse it like this:

//subsHandle holds the subs object before refresh
// after refresh, I could hold on to it like:
subsHandle = Meteor.subscribe(...)

But it's not that simple. Do you think there's a way to achieve this?

Thanks

@ready() is not a function

I'm getting these errors and have no idea why.

Uncaught TypeError: this.ready is not a function
SubsCache.SubsCache.subscribeFor.cachedSub.onReady @ subsCache.coffee:72

So I've been loggin this out, and in some cases @ doesn't refer to a subscription, but to something else. It could be related to Iron Router onWait, because I"m waiting for subscriptions like this:

    waitOn: ->
      [ 
        SubsCache.subscribe 'userDirectory',
        SubsCache.subscribe 'posts',
        SubsCache.subscribe, 'singlePost', @params.id
      ]   

so this works when

  • I navigate from another route, but when loading this route directly I get this @ready() is not a function error.
  • I use Meteor.subscribe. As soon as I change to SubsCache I get this error

Any ideas?

Subscriptions are stopped prematurely when the cache overflows

When the cache overflows SubsCache doesn't only stop subscriptions that have been held back, but may stop subscriptions that have not been stopped at all. It should instead only stop subscriptions that have had stop called on them, but have not yet actually been stopped because of the caching.

The current behaviour is surprising and does not conform the the documented behaviour: "cacheLimit is the max number of subscriptions to cache".

onReady callback causes infinite loop in template.autorun

Sample code below with onReady callback goes into an infinite AUTORUN loop:

Template.users.onCreated(function() {
    const template = this
    template.usersReady = new ReactiveVar(false)
    template.userLimit = new ReactiveVar(10)
    template.autorun(function() {
        console.log('AUTORUN')
        const subUsers = subsCache.subscribe('users', template.userLimit.get(), {
            onReady: function () {
                template.usersReady.set(true)
            }
        })
    })
})

The code below does not:

Template.users.onCreated(function() {
    const template = this
    template.usersReady = new ReactiveVar(false)
    template.userLimit = new ReactiveVar(10)
    template.autorun(function() {
        console.log('AUTORUN')
        const subUsers = subsCache.subscribe('users', template.userLimit.get())
        if (subUsers.ready()) {
            template.usersReady.set(true)
        }
    })
})

When subs are combined, the combined sub stops when the first sub is stopped, not the last

Consider a page with two independent sections (A and B) that both make a subscription with the same arguments.

  1. A loads and creates subscription a.
  2. B loads and creates subscription b (which SubsCache combines with a).
  3. A unloads, stopping a.

Observed: at this point, the SubsCache subscription is delayedStoped. After the timeout, the real subscription is stopped, clearing the data that B is using.

Expected: the subscription is not stopped until b is stopped.

Exception in queued task: Error: Can't set timers inside simulations

I am experiencing the following exception when using SubsCache in conjunction with Iron Router:

Exception in queued task: Error: Can't set timers inside simulations
    at withoutInvocation (http://10.1.1.50:3000/packages/meteor.js?43b7958c1598803e94014f27f5f622b0bddc0aaf:434:13)
    at bindAndCatch (http://10.1.1.50:3000/packages/meteor.js?43b7958c1598803e94014f27f5f622b0bddc0aaf:442:33)
    at Object._.extend.setTimeout (http://10.1.1.50:3000/packages/meteor.js?43b7958c1598803e94014f27f5f622b0bddc0aaf:458:23)
    at Object.SubsCache.SubsCache.subscribeFor.cachedSub.delayedStop (http://10.1.1.50:3000/packages/ccorcos_subs-cache.js?6a3225527386ddcfc7167b4226cf4ccde60559c2:165:44)
    at http://10.1.1.50:3000/packages/ccorcos_subs-cache.js?6a3225527386ddcfc7167b4226cf4ccde60559c2:156:30
    at http://10.1.1.50:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:296:31
    at Object.Tracker.nonreactive (http://10.1.1.50:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:593:12)
    at Tracker.Computation.invalidate (http://10.1.1.50:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:295:15)
    at Tracker.Dependency.changed (http://10.1.1.50:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:421:30)
    at http://10.1.1.50:3000/packages/minimongo.js?af9eb9d7447544ca9b839a3dcf7ed2da2209b56c:415:13
debug.js:41
Exception in callback of async function: Error: 

You called wait() after calling ready() inside the same computation tree.

You can fix this problem in two possible ways:

1) Put all of your wait() calls before any ready() calls.
2) Put your ready() call in its own computation with Deps.autorun.
    at Iron.utils.assert (http://10.1.1.50:3000/packages/iron_core.js?d966a1f70c94792fd94c8a155bdbef9bec5e0047:81:11)
    at http://10.1.1.50:3000/packages/iron_controller.js?b02790701804563eafedb2e68c602154983ade06:87:5
    at Array.forEach (native)
    at assertNoInvalidationLoop (http://10.1.1.50:3000/packages/iron_controller.js?b02790701804563eafedb2e68c602154983ade06:86:14)
    at WaitList.wait (http://10.1.1.50:3000/packages/iron_controller.js?b02790701804563eafedb2e68c602154983ade06:125:3)
    at Controller.wait (http://10.1.1.50:3000/packages/iron_controller.js?b02790701804563eafedb2e68c602154983ade06:442:20)
    at eachWait (http://10.1.1.50:3000/packages/iron_controller.js?b02790701804563eafedb2e68c602154983ade06:439:12)
    at Array.forEach (native)
    at Function._.each._.forEach (http://10.1.1.50:3000/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:156:11)
    at Controller.wait (http://10.1.1.50:3000/packages/iron_controller.js?b02790701804563eafedb2e68c602154983ade06:438:7)

http://10.1.1.50:3000/packages/ccorcos_subs-cache.js?6a3225527386ddcfc7167b4226cf4ccde60559c2:156:30 corresponds to subsCache.coffee:85.

My Iron Router subscription looks like:

Router.route('/ticket/:_id', {
    name: 'ticketScreen',
    waitOn: function () {
        return [
            singleSubs.subscribe('ticketById', this.params._id),
        ];
    },
    data: function() {
        return Tickets.findOne({_id: this.params._id});
    },
});

and the exception happens when the document is updated from within the page (but not if it's updated somewhere else). For example:

Tickets.update('RjfW8d8Q93MupLXfJ', {$set: {notes:"yolo"}})

An advise is needed in the Readme about subscriptions started inside a Tracker

We discovered that subscriptions started inside an autorun are stopped when Tracker is stopped.

This is not what we expected and was causing errors in our app.

Is it possible to add a param with the subscription to indicate if it has to be stopped or not? Or something similar...
Now autoruns are stopped when templates are destroyed, so maybe there's no need for this convenience.

Thanks

Code conversion to JavaScript

Hello,

Is there any chance to convert code to JavaScript?

In that case, we can maintain it at my company. We use your component in one of our biggest project, so we will have it up and running for quite long time. Must say that we do not use CoffeScript at all.

Let me know what you think.

And thanks a lot for your amazing job.

Multiple subscription with same name

Hey,
I have a problem with the recent version of this package.
The problem is, that subs-cache updates the subscription if a paramter changes (except first param).
If I have two subscriptions on the same page, the last called subsribe will update the first one.

SubsCache.subscribe('user', id1);
SubsCache.subscribe('user', id2);

In the older versions of this package, multiple cached subscriptions were possible.
I think it is related to the hash calculation (you only use the first param for it).

Does subscription caching break pagination?

Was just wondering if you use a subscription cache for paging through documents using a skip, limit, and sort, for example, as you page through the documents, those documents will get retained and build up in minimongo on the client.

You'll then need to update your client code to paginate through them correctly. Where with just using regular pub/sub you only have the current page of documents on the client, so you code can just return the currently published set of documents (which is really the current page).

If you update your client code to pass skip, limit, and sort to a minimongo query, in order to retrieve the correct page of documents from all the cached documents, what happens when the cached subscriptions expire in the middle of all this?

Seems like that would throw a wrench into everything... like sand shifting underneath your minimongo code.

Reasons for deprecation?

Hi @ccorcos,

We only recently started using this package, to replace SubsManager that's causing us some problems. But I just found out about the deprecation notice you added a few days ago. Could you share the reasons โ€“ is it because you don't plan to maintain it anymore or are there some serious issues with the approach of taken by this library?

Thanks.

Incompatibility with tmeasday:publish-counts?

When using subs-cache to manage a subscription that has a Counts.publish, after a subscription is stopped - sub.stop() - and then re-started (re-subscribing again), the published counts stop being pushed to the client via DDP... If it is not stopped and just re-subscribed (for example if it is subscribed within a autorun in a Template onCreate callback due to change on criteria), all works fine.

Any idea?

Exception in queued task: Error: Can't set timers inside simulations

Hello,

This error occurs when i'm deleting an entity that has been subs-cached. I've seen that it already happened in #4 and #10.

Exception in queued task: Error: Can't set timers inside simulations
    at withoutInvocation (http://localhost:3000/packages/meteor.js?hash=ae8b8affa9680bf9720bd8f7fa112f13a62f71c3:463:13)
    at bindAndCatch (http://localhost:3000/packages/meteor.js?hash=ae8b8affa9680bf9720bd8f7fa112f13a62f71c3:471:33)
    at Object.setTimeout (http://localhost:3000/packages/meteor.js?hash=ae8b8affa9680bf9720bd8f7fa112f13a62f71c3:487:23)
    at Object.delayedStop (http://localhost:3000/packages/ccorcos_subs-cache.js?hash=42b5cad3111cb64c8824058a364c995113d9f827:218:44)
    at http://localhost:3000/packages/ccorcos_subs-cache.js?hash=42b5cad3111cb64c8824058a364c995113d9f827:209:30
    at http://localhost:3000/packages/tracker.js?hash=f525263111eb9d90f4ce1ad064f97aca4a6c1b07:302:31
    at Object.Tracker.nonreactive (http://localhost:3000/packages/tracker.js?hash=f525263111eb9d90f4ce1ad064f97aca4a6c1b07:631:12)
    at Tracker.Computation.invalidate (http://localhost:3000/packages/tracker.js?hash=f525263111eb9d90f4ce1ad064f97aca4a6c1b07:301:15)
    at Tracker.Computation.stop (http://localhost:3000/packages/tracker.js?hash=f525263111eb9d90f4ce1ad064f97aca4a6c1b07:320:10)
    at stopComputation (http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1887:44) undefined
debug.js:43 Clock discrepancy detected. Attempting re-sync. undefined

The entity is beeing deleted as expected, but it appears to still be in the cache and the templates aren't refreshed as expected. I've found no workaround so far...

onReady callback isn't called when subscription is already active

When providing an onReady callback to Meteor.subscribe, it will always be called, even if an identical subscription is already active. subsCache.subscribe does not behave in this way; if a subscription with the same arguments already exists, the callback is ignored.

For example

var l = function() { console.log("onReady"); };
var sc = new SubsCache({
  expireAter: 5,
  cacheLimit: 10
});

Meteor.subscribe("mysub", l); // "onReady"
Meteor.subscribe("mysub", l); // "onReady"

sc.subscribe("mysub", l); // "onReady"
sc.subscribe("mysub", l); // nothing, never

Is subscription determined to be active before being stopped on limit reach?

Is subscription determined to be active before being stopped on limit reach?

I was thinking about trying to determine if subscription is being active to adjust allReady(), and start caching by pages, as well as stopping the duplication of subscriptions when they have different params.
P.S.: by requiring that users pass subscriptions in the tracker.

sub.onReady() not working

This is not working, nothing shows up in the console when the onReady callback should be called. Suggestions?

const subs = new SubsCache({expireAter: 5, cacheLimit: 5});
const sub = subs.subscribe("videos", params);

sub.onReady(function() {
    console.log('hello');
}

No way this can work

The version in this package is 0.9.0 but has never been published to atmospher

screenshot 2017-07-06 10 57 33

Also, there package is trying to load src/subsCache.js but the filename is src/SubsCache.js

That plus the fact it's written in es5 and the package doesn't include ecmascript
I opened a PR #37 to fix it.

Parameter NOT working correctly

Hi guys,

there is a bug with handling constructor-parameters.

if I initiate via

export const globalSubscriptionManager = new SubsCache(
  {
    expireAfter: 11,  // Minutes to expire
    cacheLimit: -1,   // unlimited cache
    debug: Meteor.isDevelopment,
  },
)

then those parameters are not parsed correctly in the instance.

This works better in https://atmospherejs.com/blockrazor/subscache-c4 1.

There is no such publish handler named: undefined

I just switched over from subsManager, and this is the error message I'm seeing on the server:
There is no such publish handler named: undefined

Was working fine before the switch over. Any ideas?

subsCache.ready() doesn't always work

I started using this package in my production app and I'm noticing the following doesn't always work:

subsCache.ready() - tells you if all subscriptions in the cache are ready

It will regularly not return true. However, I created my own global helper that loops and checks each individual cached subscription using the sub.ready() call and it works great:

Template.registerHelper('cachedTemplateSubscriptionsReady', function() {
  const subscriptions = Template.instance().subscriptions;
  if(subscriptions) {
    for(const subscription of subscriptions) {
      if(!subscription.ready())
        return false;
    }
  }
  return true;
});

I'll try to dig into the code myself but I wanted to report this here.

Subscription Override

Hi,

After replacing some of the Meteor subscriptions to cached subscriptions some of them seem to have been overriding each other. (when one subscribes the former disappears)

I'm not sure when it happens or how to recreate this... or how to avoid it.

When making multiple subscriptions to the same point (I.e. 'post, 1', 'post, 2',[...]) how does the cache keep track and determine which subscription is which?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.