mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Improve RED.actions api to ensure actions cannot be overridden
Also alows multiple args to be passed to an action.
This commit is contained in:
		@@ -4,6 +4,12 @@ RED.actions = (function() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function addAction(name,handler) {
 | 
			
		||||
        if (typeof handler !== 'function') {
 | 
			
		||||
            throw new Error("Action handler not a function");
 | 
			
		||||
        }
 | 
			
		||||
        if (actions[name]) {
 | 
			
		||||
            throw new Error("Cannot override existing action");
 | 
			
		||||
        }
 | 
			
		||||
        actions[name] = handler;
 | 
			
		||||
    }
 | 
			
		||||
    function removeAction(name) {
 | 
			
		||||
@@ -12,9 +18,11 @@ RED.actions = (function() {
 | 
			
		||||
    function getAction(name) {
 | 
			
		||||
        return actions[name];
 | 
			
		||||
    }
 | 
			
		||||
    function invokeAction(name,args) {
 | 
			
		||||
    function invokeAction() {
 | 
			
		||||
        var args = Array.prototype.slice.call(arguments);
 | 
			
		||||
        var name = args.shift();
 | 
			
		||||
        if (actions.hasOwnProperty(name)) {
 | 
			
		||||
            actions[name](args);
 | 
			
		||||
            actions[name].apply(null, args);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    function listActions() {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user