Coder Social home page Coder Social logo

Global Subscription about mantra HOT 6 CLOSED

ickyrr avatar ickyrr commented on September 13, 2024
Global Subscription

from mantra.

Comments (6)

macrozone avatar macrozone commented on September 13, 2024 1

Notice that FlowRouter.subscriptions() is deprecated (or will get deprecated). (see https://github.com/kadirahq/flow-router#subscription-management).

I would recommend do take a close look at the mantra-sample-application and see how containers work.

In your example, you can put your subscription: Meteor.subscribe('globalPubs'); just where you have put the comment Subscription code here..

See also here for a sample: https://github.com/mantrajs/mantra-sample-blog-app/blob/master/client/modules/core/containers/post.js

from mantra.

merlinstardust avatar merlinstardust commented on September 13, 2024

Create a container for the Layout and subscribe there.

from mantra.

mmoyles87 avatar mmoyles87 commented on September 13, 2024

Another solution I have used with Mantra is to use the subs-manager plugin and create an instance of SubsManager globally in client/configs/context.js

from mantra.

ickyrr avatar ickyrr commented on September 13, 2024

Create a container for the Layout and subscribe there.
@merlinpatt Yes, I did. but it did not work.

I found a way, not sure if it's the 'proper' way to do this, I used FlowRouter.subscriptions() since it's already built in with the package.

Thanks for the help!

from mantra.

ickyrr avatar ickyrr commented on September 13, 2024

@macrozone Thanks for the heads up! I'll find other ways to do this.

from mantra.

achtan avatar achtan commented on September 13, 2024

here is how is soled 'global' subs:

layout.jsx

const Layout = ({content = () => null}) => {

  return (
    <LoadInitDataContainer>
      {content()}
    </LoadInitDataContainer>
  )
};

LoadInitDataContainer

export const composer = ({context}, onData) => {
  const {Meteor} = context();

  if(Meteor.subscribe('foo').ready()) {
    onData(null, {})
  }

};


// ------ C O M P O N E N T ----------------------------------------------------

const LoadInitData = ({children}) => {
  return children;
};

export default LoadInitData;

export const LoadInitDataContainer = composeAll(
  compose(composer),
  useDeps()
)(LoadInitData);

from mantra.

Related Issues (20)

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.