Server-side isn’t reactive, so you’ll need to put your logic in the subscribe call, and probably wrap it an an autorun. If you don’t need ‘realtime’, then maybe swap to a method and call it every X seconds.
@matt, the problem i’m having is that I have to replace all the data I have in the client then publish a new set of data since the data are based on a MYSQL query as my external source… If I don’t delete it then there will be duplicate data…
To make sure that I understand, is the issue that, without clearing the client-side collection before publishing a new set of results, the collection will contain both the new and the old results?
If so, then using two (or more) client-side collections and a little indirection may solve the problem.
Publish to one of those collections (possibly along with some metadata on each record - such as a publishedAt property indicating when the record was published) but do not access that collection directly from the UI. Instead…
Sync the data in the collection being published to with the other collection and access that other collection directly from the UI. The sync logic can be setup on an interval or triggered via reactivity.