File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed
Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -38,22 +38,27 @@ export function* fetchData(action) {
3838}
3939
4040export function * autoRefresh ( action ) {
41- while ( true ) {
42- if ( action . payload . loadImmediately ) {
43- yield call ( fetchData , action ) ;
44- }
41+ if ( action . payload . loadImmediately ) {
42+ yield call ( fetchData , action ) ;
43+ }
4544
45+ while ( true ) {
4646 const loaderState = yield select ( getLoaderState ) ;
4747 const interval = action . payload . newAutoRefreshInterval
4848 ? action . payload . newAutoRefreshInterval
4949 : loaderState [ action . meta . loader ] . config . autoRefreshInterval ;
5050
51- yield race ( [
52- call ( delay , interval ) ,
53- take ( act => act . type === LOAD && act . meta . loader === action . meta . loader ) ,
54- ] ) ;
51+ const {
52+ delayed,
53+ loadAction,
54+ } = yield race ( {
55+ delayed : call ( delay , interval ) ,
56+ loadAction : take ( act => act . type === LOAD && act . meta . loader === action . meta . loader ) ,
57+ } ) ;
5558
56- if ( ! action . payload . loadImmediately ) {
59+ if ( loadAction ) {
60+ yield call ( fetchData , loadAction ) ;
61+ } else if ( delayed ) {
5762 yield call ( fetchData , action ) ;
5863 }
5964 }
You can’t perform that action at this time.
0 commit comments