Module-documentation

version 1.0.0
module: messages version 0.0.1
size-min gzipped: 1.69 kb (incl. dependencies: kb)
dependencies: polyfill
maintanance: Marco Asbreuk
home


all modules

Messages system

This module is the basic module for creating messages. It is used to generate messages, not to process them. Other modules -like 'dialog' can process the messages and display them on the screen.

Getting Started

With nodejs:

The module messages is a typical browser-module.

In the browser:

For browser-usage, ITSA has a predefined loaderfiles. Once included, a global ITSA object with default features is available. For customized loaderfiles, read: Customized build.

<script src="/itsabuild-min.js"></script>
<script>
    
</script>
When using your own customized build-file, this module-requirement needs to be invoked with the window-object.

The Basics

messages are promises that can be generated by this module. They are promises with specific message-properties and once generated, this module will emit one of these events:

Other modules can subscribe to these events and handle the message. The idea is that the message can be handled as long as its promise is not resolved. Also, processing the message means when finished processing, the promise should be made resolved.

Generate messages

This module comes with several methods:

Available messages

The next methods all return a promise:

message

Generates a general message. Can be used directly, or used by other methods (like alert)

alert

Generates a simple message.

warn

Generates an alert.

prompt

Generates an prompt with an input-element.

General Methods

catchErrors

Method to be used to catch system-errors and redirect them through the message-system.

Example alert

ITSA.alert('I am an alert');

Note: the dialog-module takes care of handling this message

Handling messages

Messages need to be handled by separate modules. The dialog-module for example, is set up to handle all '.message', ':warn' and '*:error' messages by default. If you create you own message-handler, you could create a before-listener to handle some of these messages and use e.halt() to prevent them from reaching dialog.

API Docs