state
= state
Controller
= state's controller
Last active
August 29, 2015 14:23
-
-
Save stryju/3eba66f90848f0cb376c to your computer and use it in GitHub Desktop.
preferred state $http resolution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const state = { | |
resolve : { | |
foo : ( $http ) => $http.get( '/foo' ) | |
}, | |
controller : Controller | |
} | |
class Controller { | |
constructor( foo ) { | |
this.foo = foo.data; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const state = { | |
resolve : { | |
foo : ( $http ) => $http.get( '/foo' ).then( ( response ) => response.data ) | |
}, | |
controller : Controller | |
} | |
class Controller { | |
constructor( foo ) { | |
this.foo = foo; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const state = { | |
resolve : { | |
foo : ( $q, $http ) => { | |
const request = $http.get( '/foo' ); | |
return $q( ( resolve, reject ) => request.success( resolve ).error( reject ) ) | |
}, | |
controller : Controller | |
} | |
class Controller { | |
constructor( foo ) { | |
this.foo = foo; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const state = { | |
resolve : { | |
foo : ( $q, $http ) => { | |
const deferred = $q.defer(); | |
$http.get( '/foo' ).success( deferred.resolve ).error( deferred.reject ); | |
return deferred.promise; | |
}, | |
controller : Controller | |
} | |
class Controller { | |
constructor( foo ) { | |
this.foo = foo; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
04.es6: