Last active
January 16, 2016 00:28
-
-
Save lsanwick/577a047bd1f44a2e5919 to your computer and use it in GitHub Desktop.
Alt JS Loading Bug
This file contains 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
OrderSource = { | |
fetchOrders: { | |
remote: -> axios.get('/orders.json'), | |
loading: OrderActions.loadingOrders, | |
success: OrderActions.fetchOrdersCompleted, | |
error: OrderActions.fetchOrdersFailed, | |
} | |
} | |
module.exports = OrderSource |
This file contains 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
class OrdersPage extends React.Component | |
@getStores: (props) -> | |
[OrderStore] | |
@getPropsFromStores: (props) -> | |
OrderStore.getState() | |
componentDidMount: -> | |
OrderStore.fetchOrders() | |
loadingIndicator: -> | |
return unless @props.loading | |
<FontAwesome className="loading-indicator" name="refresh" size="2x" spin /> | |
render: -> | |
<div> | |
{@loadingIndicator()} | |
</div> | |
module.exports = connectToStores(OrdersPage) |
This file contains 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
class OrderStore | |
constructor: -> | |
@orders = [] | |
@error = null | |
@loading = false | |
@bindActions(OrderActions) | |
@registerAsync(OrderSource) | |
onLoadingOrders: -> | |
@error = null | |
@loading = true | |
@orders = [] | |
onFetchOrdersCompleted: (response) -> | |
@error = null | |
@loading = false | |
@orders = response.data if response.status == 200 | |
module.exports = alt.createStore(OrderStore, 'OrderStore') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment