Sha256: 70fe32bb4174e03a23734430375e61994409796be31fb6f4963711dd6ec111dd

Contents?: true

Size: 850 Bytes

Versions: 2

Compression:

Stored size: 850 Bytes

Contents

import * as api from '../api/Api';
export const FETCH    = 'FETCH';
export const CREATE   = 'CREATE';
export const DELETE   = 'DELETE';
export const SHOW_ALL = 'SHOW_ALL';

export function fetch(id) {
  return ((dispatch) => {
    api.fetch(id)
      .then((messages) => dispatch({ type: FETCH, data: messages.data }));
  });
}

export function create(body, sender, conversation, senderClass) {
  return ((dispatch) => {
    api.createMessage(body, sender, conversation, senderClass)
      .then((message) => dispatch({ type: CREATE, message: message.data }));
  });
}

export function deleteMessage(id, conversation) {
  return ((dispatch) => {
    api.deleteMessage(id, conversation)
      .then((response) => dispatch({ type: DELETE, data: response.data, id: id }));
  });
}

export function showAll() {
  return { type: SHOW_ALL, data: true };
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
denshobato_chat_panel-0.0.2 lib/react/actions/Messages.jsx
denshobato_chat_panel-0.0.1 lib/react/actions/Messages.jsx