Module: EventBusDispatcher

EventBusDispatcher

EventBusDispatcher Provider
Author:
  • Marco Lehmann <marco.lehmann (at) kiwigrid.com>
Source:

Classes

ketaEventBusDispatcher
ketaEventBusDispatcherProvider

Members

<inner, constant> RESPONSE_CODE_AUTHENTICATION_TIMEOUT

Response code 419.

Source:
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        if (responseCode === ketaEventBusDispatcher.RESPONSE_CODE_AUTHENTICATION_TIMEOUT) {
            // ...
        }
    });

<inner, constant> RESPONSE_CODE_BAD_REQUEST

Response code 400.

Source:
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        if (responseCode === ketaEventBusDispatcher.RESPONSE_CODE_BAD_REQUEST) {
            // ...
        }
    });

<inner, constant> RESPONSE_CODE_INTERNAL_SERVER_ERROR

Response code 500.

Source:
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        if (responseCode === ketaEventBusDispatcher.RESPONSE_CODE_INTERNAL_SERVER_ERROR) {
            // ...
        }
    });

<inner, constant> RESPONSE_CODE_NO_CONTENT

Response code 204.

Source:
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        if (responseCode === ketaEventBusDispatcher.RESPONSE_CODE_NO_CONTENT) {
            // ...
        }
    });

<inner, constant> RESPONSE_CODE_NOT_FOUND

Response code 404.

Source:
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        if (responseCode === ketaEventBusDispatcher.RESPONSE_CODE_NOT_FOUND) {
            // ...
        }
    });

<inner, constant> RESPONSE_CODE_OK

Response code 200.

Source:
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        if (responseCode === ketaEventBusDispatcher.RESPONSE_CODE_OK) {
            // ...
        }
    });

<inner, constant> RESPONSE_CODE_REQUEST_TIMEOUT

Response code 408.

Source:
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        if (responseCode === ketaEventBusDispatcher.RESPONSE_CODE_REQUEST_TIMEOUT) {
            // ...
        }
    });

<inner, constant> RESPONSE_CODE_SERVICE_UNAVAILABLE

Response code 503.

Source:
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        if (responseCode === ketaEventBusDispatcher.RESPONSE_CODE_SERVICE_UNAVAILABLE) {
            // ...
        }
    });

<inner, constant> RESPONSE_CODE_UNAUTHORIZED

Response code 401.

Source:
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        if (responseCode === ketaEventBusDispatcher.RESPONSE_CODE_UNAUTHORIZED) {
            // ...
        }
    });

<inner, constant> RESPONSE_MESSAGE_AUTHENTICATION_TIMEOUT

Response message 419.

Source:
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        if (responseMessage === ketaEventBusDispatcher.RESPONSE_MESSAGE_AUTHENTICATION_TIMEOUT) {
            // ...
        }
    });

<inner, constant> RESPONSE_MESSAGE_BAD_REQUEST

Response message 400.

Source:
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        if (responseMessage === ketaEventBusDispatcher.RESPONSE_MESSAGE_BAD_REQUEST) {
            // ...
        }
    });

<inner, constant> RESPONSE_MESSAGE_INTERNAL_SERVER_ERROR

Response message 500.

Source:
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        if (responseMessage === ketaEventBusDispatcher.RESPONSE_MESSAGE_INTERNAL_SERVER_ERROR) {
            // ...
        }
    });

<inner, constant> RESPONSE_MESSAGE_NOT_FOUND

Response message 404.

Source:
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        if (responseMessage === ketaEventBusDispatcher.RESPONSE_MESSAGE_NOT_FOUND) {
            // ...
        }
    });

<inner, constant> RESPONSE_MESSAGE_OK

Response message 200.

Source:
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        if (responseMessage === ketaEventBusDispatcher.RESPONSE_MESSAGE_OK) {
            // ...
        }
    });

<inner, constant> RESPONSE_MESSAGE_REQUEST_TIMEOUT

Response message 408.

Source:
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        if (responseMessage === ketaEventBusDispatcher.RESPONSE_MESSAGE_REQUEST_TIMEOUT) {
            // ...
        }
    });

<inner, constant> RESPONSE_MESSAGE_SERVICE_UNAVAILABLE

Response message 503.

Source:
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        if (responseMessage === ketaEventBusDispatcher.RESPONSE_MESSAGE_SERVICE_UNAVAILABLE) {
            // ...
        }
    });

<inner, constant> RESPONSE_MESSAGE_UNAUTHORIZED

Response message 401.

Source:
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        if (responseMessage === ketaEventBusDispatcher.RESPONSE_MESSAGE_UNAUTHORIZED) {
            // ...
        }
    });

<inner, constant> STATE_CLOSED

Closed state constant.

Source:
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        if (state === ketaEventBusDispatcher.STATE_CLOSED) {
            // ...
        }
    });

<inner, constant> STATE_CLOSING

Closing state constant.

Source:
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        if (state === ketaEventBusDispatcher.STATE_CLOSING) {
            // ...
        }
    });

<inner, constant> STATE_CONNECTING

Connecting state constant.

Source:
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        if (state === ketaEventBusDispatcher.STATE_CONNECTING) {
            // ...
        }
    });

<inner, constant> STATE_OPEN

Open state constant.

Source:
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        if (state === ketaEventBusDispatcher.STATE_OPEN) {
            // ...
        }
    });

Methods

<inner> close(eventBus) → {void}

Closes connection to specified EventBus instance.

Parameters:
Name Type Description
eventBus EventBus EventBus instance
Source:
Returns:
void returns nothing
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        ketaEventBusDispatcher.close(eventBus);
    });

<inner> generateUUID() → {string}

Generates an UUID for handler.

Source:
Returns:
string uuid
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        var handlerUUID = ketaEventBus.generateUUID();
    });

<inner> publish(eventBus, address, message) → {void}

Publish a message to a specified address using the specified EventBus instance.

Parameters:
Name Type Description
eventBus EventBus EventBus instance
address string unique address on EventBus instance
message object message object to send
Source:
Returns:
void returns nothing
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        ketaEventBusDispatcher.publish(eventBus, 'address', {
            action: 'action',
            body: {
                guid: 'guid'
            }
        });
    });

<inner> readyState(eventBus) → {number}

Returns connection state of specified EventBus instance.

Parameters:
Name Type Description
eventBus EventBus EventBus instance
Source:
Returns:
number connection state
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        var state = ketaEventBusDispatcher.readyState(eventBus);
    });

<inner> registerHandler(eventBus, address, handler) → {void}

Registers a handler on a specified address using the specified EventBus instance.

Parameters:
Name Type Description
eventBus EventBus EventBus instance
address string unique address on EventBus instance
handler function handler to process messages coming in from EventBus instance
Source:
Returns:
void returns nothing
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        ketaEventBusDispatcher.registerHandler(eventBus, 'address', function(event) {
            // ...
        });
    });

<inner> send(eventBus, address, message, replyHandler) → {void}

Send a message to a specified address using the specified EventBus instance and the specified replyHandler.

There is a reply interceptor to check whether the access token injected automatically is expired or not. If it's expired the AccessToken service is used to refresh it and repeat the original request. If access token could not be refreshed a full page reload is performed which usually results in a redirection to the OAuth server.

Parameters:
Name Type Description
eventBus EventBus EventBus instance
address string unique address on EventBus instance
message object message object to send
replyHandler function handler to process reply
Source:
See:
  • AccessToken.refresh
Returns:
void returns nothing
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        ketaEventBusDispatcher.send(eventBus, 'address', {
            action: 'action',
            body: {
                guid: 'guid'
            }
        }, function(reply) {
            // ...
        });
    });

<inner> unregisterHandler(eventBus, address, handler) → {void}

Unregisters a handler on a specified address using the specified EventBus instance.

Parameters:
Name Type Description
eventBus EventBus EventBus instance
address string unique address on EventBus instance
handler function handler to process messages coming in from EventBus instance
Source:
Returns:
void returns nothing
Example
angular.module('exampleApp', ['keta.services.EventBusDispatcher'])
    .controller('ExampleController', function(ketaEventBusDispatcher) {
        ketaEventBusDispatcher.unregisterHandler(eventBus, 'address', function(event) {
            // ...
        });
    });