0.1.3 • Published 7 years ago

fh-wfm-message v0.1.3

Weekly downloads
28
License
MIT
Repository
github
Last release
7 years ago

FeedHenry RainCatcher message Build Status

This module contains a message model representation and its related services :

  • Backend services
  • Frontend services
  • Frontend UI templates

Client-side usage

Setup

This module is packaged in a CommonJS format, exporting the name of the Angular namespace. The module can be included in an angular.js as follows:

angular.module('app', [
, require('fh-wfm-message')
...
])

Integration

Angular Service

This module publishes and subscribes to sync

A sync manager must first be initialized using the messageSync.createManager(). This can be placed, for instance, in the resolve config of a ui-router controlled application.

resolve: {
  messageManager: function(messageSync) {
    return messageSync.createManager();
  }
}

For a more complete example, please check the demo portal app.

messageSync API

These messageSync API methods all return Promises:

messageSync methodDescription
messageSync.manager.listlist all messages
messageSync.manager.create(message)create a message
messageSync.manager.read(messageId)read a message
messageSync.manager.update(message)update a message
messageSync.manager.delete(message)delete a message

message directives

NameAttributes
message-listlist, selectedModel
message-formvalue, workers
message-detailmessage

Topic Subscriptions

wfm:messages:create

Description

Creating a new Message

Example
var parameters = {
  messageToCreate: {
    //A Valid JSON Object
  },
  //Optional topic unique identifier.
  topicUid: "uniquetopicid"
}

mediator.publish("wfm:messages:create", parameters);

wfm:messages:read

Description

Read a single Message

Example
var parameters = {
  id: "messageId",
  //Optional topic unique identifier.
  topicUid: "uniquetopicid"
}

mediator.publish("wfm:messages:read", parameters);

wfm:messages:update

Description

Update a single Message

Example
var parameters = {
  messageToUpdate: {
    ...
    id: "messageId"
    ...
  },
  //Optional topic unique identifier.
  topicUid: "uniquetopicid"
}

mediator.publish("wfm:messages:update", parameters);

wfm:messages:remove

Description

Remove a single Message

Example
var parameters = {
  id: "messageId",
  //Optional topic unique identifier.
  topicUid: "uniquetopicid"
}

mediator.publish("wfm:messages:remove", parameters);

wfm:messages:list

Description

List All Messages

Example
var parameters = {
  //Optional topic unique identifier.
  topicUid: "uniquetopicid"
}

mediator.publish("wfm:messages:list", parameters);

Published Topics

The following topics are published by this module. Developers are free to implement these topics subscribers, or use a module that already has these subscribers implement (E.g. the raincatcher-sync module).

TopicDescription
wfm:sync:messages:createCreate a new item in the sync messages collection
wfm:sync:messages:updateUpdate an existing item in the sync messages collection
wfm:sync:messages:listList all items in the sync messages collection
wfm:sync:messages:removeRemove an existing item from the sync messages collection
wfm:sync:messages:readRead a single item from the sync messages collection
wfm:sync:messages:startStart the sync process for sync messages collection
wfm:sync:messages:stopStop the sync process for sync messages collection
wfm:sync:messages:force_syncForce a sync cycle from client to cloud for sync messages collection

Topic Subscriptions

TopicDescription
done:wfm:sync:messages:createA message was created in the messages dataset
error:wfm:sync:messages:createAn error occurred when creating an item in the messages dataset.
done:wfm:sync:messages:updateA message was updated in the messages dataset
error:wfm:sync:messages:updateAn error occurred when updating an item in the messages dataset.
done:wfm:sync:messages:listA list of the items in the messages dataset completed
error:wfm:sync:messages:listAn error occurred when listing items in the messages dataset.
done:wfm:sync:messages:removeA message was removed from the messages dataset
error:wfm:sync:messages:removeAn error occurred when removing an item in the messages dataset.
done:wfm:sync:messages:readA item was read correctly from the messages dataset
error:wfm:sync:messages:readAn error occurred when reading an item in the messages dataset.
done:wfm:sync:messages:startThe sync process started for the messages dataset.
error:wfm:sync:messages:startAn error occurred when starting the messages dataset.
done:wfm:sync:messages:stopThe sync process stopped for the messages dataset.
error:wfm:sync:messages:stopAn error occurred when stopping the messages dataset sync process.
done:wfm:sync:messages:force_syncA force sync process completed for the messages dataset.
error:wfm:sync:messages:force_syncAn error occurred when forcing the sync process for the messages dataset.

Usage in an express backend

Setup

The server-side component of this RainCatcher module exports a function that takes express and mediator instances as parameters, as in:

var express = require('express')
  , app = express()
  , mbaasExpress = mbaasApi.mbaasExpress()
  , mediator = require('fh-wfm-mediator/lib/mediator')
  ;

// configure the express app
...

// setup the wfm message sync server
require('fh-wfm-message/server')(mediator, app, mbaasExpress);

Server side events

the module broadcasts, and listens for the following events

Subscribes ToResponds with
wfm:message:listdone:wfm:message:list
wfm:message:readdone:wfm:message:read
wfm:message:updatedone:wfm:message:update
wfm:message:createdone:wfm:message:create

Integration

Check this demo cloud application

message data structure example

  {
    id: 1276001,
    receiverId: "156340",
    status: "unread",
    sender: {
      avatar:"https://s3.amazonaws.com/uifaces/faces/twitter/kolage/128.jpg",
      name:"Trever Smith"
    },
    subject: 'Adress change w41',
    content: 'hallo hallo'
  }
0.1.3

7 years ago

0.1.2

7 years ago

0.2.1-beta.1

7 years ago

0.1.1

7 years ago

0.1.1-alpha.1

7 years ago

0.1.0

7 years ago

0.1.0-alpha.4

7 years ago

0.1.0-alpha.3

7 years ago

0.1.0-alpha.2

7 years ago

0.1.0-alpha.1

7 years ago

0.0.17

7 years ago

0.0.16-alpha.2

7 years ago

0.0.16-alpha.1

7 years ago

0.0.15

7 years ago

0.0.14

7 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago