Notify-IO
Introduction
Notify-IO gives you an easy to use interface for defining and calling your own custom notifications.
1. Geting Started
The steps below will walk you through setting up a basic project to get started with notify-io
step 0: NPM install notify-io
$ npm i notify-io
step 1: Require in Notify and SchemaBuilder
const Notify SchemaBuilder =
step 2: Create new SchemaBuilder object
const schema =
step 3: Define Schema with the create function
schema
step 4: Use Notify in your project
const notify = schemanotify // info is the default state, so only call stateTo() if you need another state. const msg = notify console
step 5: The output of step 4
lang: 'en' state: 'validation' messages: key: 'username' state: 'info' code: 'welcome' message: 'welcome back some-username'
Schema Definition Types
Schemas are at the core of Notify-IO. Here we will take a look at the three types of Schemas, specifically how they are defined and when what type is used. Schema types are distinguished based on the mount of arguments the schema function takes.
The three types are:
- Constant Schema Definition (CSD)
- Unary Schema Definition (USD)
- Multidimensional Schema Definition (MSD)
Note: keys must be valid ISO 639-1 lang codes e.g. "en"
Constant Schema Definition (CSD)
schema
Unary Schema Definition (USD)
schema
Multidimensional Schema Definition (MSD)
schema
API Documentation
.message()
The message method has three parameters. The first is required and the other two are optional. Notify-IO-Instance.message(schema-name, schema-data, message-key)
. The message method renders handles schema rendering for you.
const notify = 'validation'notify
.load()
The load method has three parameters. The first is required and the other two are optional. Notify-IO-Instance.load(schema-name, schema-data, message-key)
. The load method only loads your Schema to a queue. When you are done loading messages you can call the render method which will render all Schema in the queue.
const notify = 'validation'notify
.render()
The render method takes no parameters. It renders all Schema in the queue.
const notify = 'validation'notify // call load as many times as you need ...