Callbacks List

You can push functions to a callbacks list, so that whenever the callbacks list is fired in future, all added functions will be invoked, in the order the functions are added.

$.Callbacks([String flags])
Return a callbacks list. 'flags' can include:'once': the callbacks list can be fire once only.'memory': fires the new function with the previous value when the function has been just added.'unique': a function can only be added once.'stopOnFalse': do not invoke the subsequent functions when a function returns false.
callbacks.add(function(...)/Array f)
Add a function or array of functions.
callbacks.disable()
Disable a callback list from doing anything more. Prevent both adding and firing.
callbacks.empty()
Remove all functions.
callbacks.fire(Any arguments)
Invoke all functions with the specified arguments.
callbacks.fireWith([Object context][, Any arguments])
Invoke all function with the specified arguments within the specified context.
callbacks.lock()
Lock the current state. Prevent firing but allow adding. In a 'memory' callbacks list, a new function may still be invoked.
callbacks.remove(function()/Array f)
Remove a function or array of functions.
callbacks.disabled()callbacks.fired()callbacks.has([function() f])callbacks.locked()Check the various states of the callbacks list.

RESETRUNFULL
<!DOCTYPE html><html><head><script src="jquery-3.5.1.min.js"></script></head><body>
   <p></p>
   <script>
    function f1(msg){alert('f1');}
   function f2(msg){alert('f2');}
   function f3(msg){alert('f3');}
   var cl = $.Callbacks();
   cl.add(f1)
     .add([f2,f3])
     .remove(f2)
     .fire()  // f1 f3
     .disable()
     .fire();  // (nothing)
   </script> </body></html>

RESETRUNFULL
<!DOCTYPE html><html><head>
   <script src="jquery-3.5.1.min.js"></script></head><body>
   <p></p>
   <script>
    function f1(msg){alert('f1: '+msg);}
   function f2(msg){alert('f2: '+msg);}
   var cl = $.Callbacks('memory');
   cl.add(f1);
   cl.fire('A');  // f1: A
   cl.add(f2);  // f2: A
   cl.fire('B');  // f1: B                    // f2: B
   </script> </body></html>