Closed udayms closed 11 years ago
You could use a normal timeout:
Messenger().post('test');
setTimeout(myFunction, 5000);
Is your goal to always call a specific function X seconds after any message is shown?
I want something where I can pass to the Messenger call a function that will be fired after the message disappears.
Maybe something like - Messenger().post('Hello', function(){ console.log("function fired after message display!"); });
OR something like - Messenger().post('Hello', fn);
var fn = function(){ console.log("function fired after message display!"); }
OR - Messenger().post({ message: 'hello', callback: fn });
Somehow setTimeout has always seemed like a hack to me :) I would be more comfortable with something callback or event driven.
My two cents :)
Sure, you can bind on to the hide event on the message:
var msg = Messenger().post("test")
msg.on('hide', function(){
// Anything you need
});
How can I display a message, wait for X seconds and then fire a function?