Meteor method returning a stream?


#1

Hey!

Does anyone know if I can call a Meteor method which returns a stream, instead of just returning once?

I’m using the Noble.js NPM package via the meteorhacks:npm package to scan for Bluetooth peripherals, and the noble.on(‘discover’, callback) is a callback that outputs a stream of data whenever it finds new peripherals:
[image: http://i.imgur.com/UDZ0RfB.png]

Now to the real question: how do I return that stream to the client? I’ve tried using Fibers/Future, returning directly from within the noble.on() callback, etc., but either nothing shows up, or Meteor crashes (maximum callstack).

Any ideas?


#2

No, Meteor methods can only return EJSON serializable values.

You can create a new Collection and use a publication and subscription instead :wink:

You can also create a Collection that is not stored into MongoDB on the sever by passing null as name (mention in docs). I have never done this, but others have. Just google for it.


#3

Sounds like an OK idea, actually. I just implemented a streaming function using Streamy. It’s kinda hackish, but at least it works as of now. I’ll check into your suggestion as well, as an alternative. Thanks!


#4

Hi have a look at this thread: Meteor and the Internet of Things (IoT) - whats best to use? Collection, Meteor-Streams, Streamy