Closed jeffrose closed 11 years ago
I followed the least astonishment principle. If we add something like memorySize
what is the desired behavior with multiple listeners?
var initialized = new Signal();
iniltialized.memorize = true;
initialized.memorySize = -1; // lets suppose this feature exists
initialized.dispatch('lorem');
initialized.dispatch('ipsum');
initialized.add(console.log, console);
// > "lorem"
// > "ipsum"
// should `echo` be called once or twice?
initialized.add(echo);
I can see the use for a feature like that - specially if you want to implement something like a Stream
(and don't want to lose any data) - but it would increase complexity a little bit. Any special use case for it that justifies the overhead?
I was looking to migrate my current pub-sub system from a
$.Callbacks
implementation to one based on Signals in the hope of having a more robust solution. So far everything seems fine except for memorization.$.Callbacks
have a long-term memory...... whereas Signals seem to have a short-term memory...
Have you considered adding a memory size option or similar to allow more dispatches to memorized?