Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var React = require('react');
- var SelectPolicies = require('../components/SelectPolicies.react');
- var CustomerStore = require('../stores/CustomerStore');
- var CustomerRepository = require('../repositories/CustomerRepository');
- var SelectPoliciesController = React.createClass({
- displayName: "SelectPoliciesController.react",
- componentWillMount: function () {
- //initiate ajax call
- CustomerRepository.getCustomer();
- return true;
- },
- var CustomerRepository = {
- getCustomer: function() {
- var xhr = new XMLHttpRequest();
- xhr.open("get", "/api/customer", true);
- xhr.onload = function () {
- var customer = JSON.parse(xhr.responseText);
- Actions.receiveCustomer(customer);
- }.bind(this);
- xhr.send();
- }
- }
- var AppDispatcher = require('../dispatcher/AppDispatcher');
- var AppConstants = require('../constants/AppConstants');
- var CustomerActions = {
- receiveCustomer: function (customer) {
- var action = {
- actionType: AppConstants.RECEIVE_CUSTOMER,
- customer: customer
- };
- AppDispatcher.dispatch(action);
- },
- };
- module.exports = CustomerActions;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement