Skip to content

Question: subscribe with unblock and then later do a blocking subscription #4

@funkyeah

Description

@funkyeah

I am wondering what would happen if you pass whether to unblock or not in a subscribe and then later re-subscribe with block.

An example of the pattern I want to support is subscribing to data used to populate a dropdown menu. When I render the page I know I need to get that data eventually but because the data is used in an a drop-down it is lower-priority to get . So originally this.unblock is good. But then lets say a user clicks the drop-down and the data hasn't loaded yet. At that point I would like to re-subscribe without unblocking since that data is now time critical.

Is this something that should work as shown below? Is there any merit to the idea of extending unblock into a priority/yielding scheme, where lower priority publishes yield to higher priority ones?

  if Meteor.isServer    
    Meteor.publish 'mycollection',  (unblock) ->
      if unblock
        @unblock()
      Collection.find({})

  if Meteor.isClient
    # eventually want the data but not critical
    Meteor.subscribe('mycollection', true)

    # need the data to render properly
    Meteor.subscribe('mycollection', false)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions