Skip to content

Commit

Permalink
Merge pull request #64 from jpcapurro-atixlabs/add-automatic-refresh
Browse files Browse the repository at this point in the history
Add automatic refresh
  • Loading branch information
NicolasDP committed Oct 22, 2019
2 parents 975b126 + 7fa4244 commit 8f08744
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
27 changes: 20 additions & 7 deletions examples/wallet/app/containers/Root.js
Expand Up @@ -3,20 +3,33 @@ import React from 'react';
import { Provider } from 'react-redux';
import { ConnectedRouter } from 'connected-react-router';
import { hot } from 'react-hot-loader/root';
import config from 'config';
import type { Store } from '../reducers/types';
import Routes from '../Routes';
import { updateBalanceAndCounter } from '../actions/account';

type Props = {
store: Store,
history: {}
};

const Root = ({ store, history }: Props) => (
<Provider store={store}>
<ConnectedRouter history={history}>
<Routes />
</ConnectedRouter>
</Provider>
);
const Root = ({ store, history }: Props) => {
// This does not take into consideration what happeneda to the last request
// if the previous request didn't finish, it just launches another one.
// this of course causes race conditions and it can be problematic to open infinite
// connections, but in the near future we should subscribe to the gRPC gossip and
// no longer require polling.
setInterval(
() => store.dispatch(updateBalanceAndCounter()),
config.get('pollingInterval')
);
return (
<Provider store={store}>
<ConnectedRouter history={history}>
<Routes />
</ConnectedRouter>
</Provider>
);
};

export default hot(Root);
1 change: 1 addition & 0 deletions examples/wallet/config/default.json
@@ -1,4 +1,5 @@
{
"pollingInterval": 10000,
"networkDiscrimination": "testnet",
"addressPrefix": "ca",
"nodeUrl": "http://localhost:8443",
Expand Down

0 comments on commit 8f08744

Please sign in to comment.