I have a simple Meteor subscription, and I display a loading message while the data is being loaded. But I don't know how to display error message if subscription failed.
export const MyAwesomeComponent = createContainer(() => {
let sub = Meteor.subscribe('some-data');
if (!sub.ready()) return { message: 'Loading...'};
if (sub.failed()) return { message: 'Failed.' }; // How to do this?
return {
data: Data.find().fetch()
}
}, MyInternalRenderComponent);
Problem is, the subscription object doesn't have a failed()
method, only a ready()
query. How to pass the failure of a subscription as props in a createContainer()
method?
I know the Meteor.subscribe
method has an onStop
callback for this case, but I don't know how to glue it toghether that to pass a property.