Permalink
Browse files

Step 18: Update '~/actions/miniDashboardActions.js' to listen to your…

… back-end service.
  • Loading branch information...
embengineering committed May 22, 2016
1 parent c2a2d24 commit 9c397ab93f5acb4b1067a49be7e5bb23f142a1ba
Showing with 17 additions and 0 deletions.
  1. +16 −0 src/actions/miniDashboardActions.js
  2. +1 −0 src/constants.js
@@ -1,4 +1,8 @@
import * as CONST from '../constants';
import Firebase from 'firebase';
const welcomeCardRef = new Firebase(CONST.FIREBASE).child('welcomeMsg');
const cardListRef = new Firebase(CONST.FIREBASE).child('cards');
export const displayWelcomeCard = (data) => ({
type: CONST.DISPLAY_WELCOME_CARD,
@@ -9,3 +13,15 @@ export const displayCardList = (data) => ({
type: CONST.DISPLAY_CARD_LIST,
data: data
});
export const startListeningToWelcomeCard = () => (dispatch) => {
welcomeCardRef.on('value', (snapshot) => {
dispatch(displayWelcomeCard(snapshot.val()));
});
};
export const startListeningToCardList = () => (dispatch) => {
cardListRef.on('value', (snapshot) => {
dispatch(displayCardList(snapshot.val()));
});
};
@@ -1,2 +1,3 @@
export const DISPLAY_WELCOME_CARD = 'DISPLAY_WELCOME_CARD';
export const DISPLAY_CARD_LIST = 'DISPLAY_CARD_LIST';
export const FIREBASE = 'https://mini-dashboard.firebaseio.com/';

0 comments on commit 9c397ab

Please sign in to comment.