Closed jetlej closed 7 years ago
Hm, this sounds like it would best be done using collection.observe. So, whenever the change you're waiting for happens, on the client, you can call Bert.
For example:
Badges.find({ userId }).observe({
added() {
Bert.alert('You got a new badge!', 'success');
}
});
It always shows an alert message whether a new record is added or not. If a new record added, the alert is shown twice.
@aniskhan001 this will fire whenever the client receives data (e.g., the result of a publication being subscribed to technically fires an "added" event because docs are being added from the server).
Hello, i face the same Problem:
import { Bert } from 'meteor/themeteorchef:bert';
...
Meteor.methods({
'foo'() {
Bert.alert(...);
},
});
results in TypeError: Cannot call method 'alert' of undefined
@Gobliins Bert is only intended for use on the client, so you'll need to use it in the callback to your Method call like:
Meteor.call('myMethod', {}, (error, response) => {
if (error) {
Bert.alert(error.reason, 'danger');
} else {
Bert.alert('Success message', 'success');
}
});
How can I create a Bert Alert from within a server-side Meteor method?
I have a system that awards badges in the background while users actions occur on the front-end, and I want to tell them as soon as they have been rewarded a new badge.