Advertisement
Guest User

Untitled

a guest
Apr 17th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var ApiRequestMixin = function(url, success, error) {
  2.     apiRequestIds: [],
  3.    
  4.     componentDidMount: function() {
  5.         var requestId = api.request(url, {
  6.             success: success.bind(this),
  7.             error: error.bind(this)
  8.         });
  9.        
  10.         this.apiRequestIds.push(requestId);
  11.     },
  12.    
  13.     componentWillUnmount: function() {
  14.         api.cancelRequests(this.apiRequestIds);
  15.     },
  16. }
  17.  
  18. React.createClass({
  19.     mixins: [
  20.         ApiRequestMixin('http://...',
  21.             function() {
  22.                 success...
  23.             },
  24.             function() {
  25.                 error...
  26.             }
  27.     ],
  28. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement