File tree Expand file tree Collapse file tree 3 files changed +24
-42
lines changed
examples/type-portability
bundler/src/features/polling
nodenext-cjs/src/features/polling
nodenext-esm/src/features/polling Expand file tree Collapse file tree 3 files changed +24
-42
lines changed Original file line number Diff line number Diff line change 1
- import type { PayloadAction } from '@reduxjs/toolkit'
2
1
import { createSlice } from '@reduxjs/toolkit'
3
2
import type { RootState } from '../../app/store'
4
3
@@ -37,27 +36,22 @@ export type PollingAppKey = keyof (typeof initialState)['apps']
37
36
export const pollingSlice = createSlice ( {
38
37
name : 'polling' ,
39
38
initialState,
40
- reducers : ( creators ) => {
39
+ reducers : ( create ) => {
41
40
return {
42
- toggleGlobalPolling : creators . reducer ( ( state ) => {
41
+ toggleGlobalPolling : create . reducer ( ( state ) => {
43
42
state . enabled = ! state . enabled
44
43
} ) ,
45
- updatePolling (
46
- state ,
47
- {
48
- payload,
49
- } : PayloadAction < {
50
- app : PollingAppKey
51
- enabled ?: boolean
52
- interval ?: number
53
- } > ,
54
- ) {
44
+ updatePolling : create . reducer < {
45
+ app : PollingAppKey
46
+ enabled ?: boolean
47
+ interval ?: number
48
+ } > ( ( state , { payload } ) => {
55
49
const { app, ...rest } = payload
56
50
state . apps [ app ] = {
57
51
...state . apps [ app ] ,
58
52
...rest ,
59
53
}
60
- } ,
54
+ } ) ,
61
55
}
62
56
} ,
63
57
selectors : {
Original file line number Diff line number Diff line change 1
1
import ReduxToolkit = require( '@reduxjs/toolkit' )
2
2
3
- import type { PayloadAction } from '@reduxjs/toolkit'
4
3
import type { RootState } from '../../app/store.js'
5
4
6
5
namespace pollingSliceModule {
@@ -41,27 +40,22 @@ namespace pollingSliceModule {
41
40
export const pollingSlice = createSlice ( {
42
41
name : 'polling' ,
43
42
initialState,
44
- reducers : ( creators ) => {
43
+ reducers : ( create ) => {
45
44
return {
46
- toggleGlobalPolling : creators . reducer ( ( state ) => {
45
+ toggleGlobalPolling : create . reducer ( ( state ) => {
47
46
state . enabled = ! state . enabled
48
47
} ) ,
49
- updatePolling (
50
- state ,
51
- {
52
- payload,
53
- } : PayloadAction < {
54
- app : PollingAppKey
55
- enabled ?: boolean
56
- interval ?: number
57
- } > ,
58
- ) {
48
+ updatePolling : create . reducer < {
49
+ app : PollingAppKey
50
+ enabled ?: boolean
51
+ interval ?: number
52
+ } > ( ( state , { payload } ) => {
59
53
const { app, ...rest } = payload
60
54
state . apps [ app ] = {
61
55
...state . apps [ app ] ,
62
56
...rest ,
63
57
}
64
- } ,
58
+ } ) ,
65
59
}
66
60
} ,
67
61
selectors : {
Original file line number Diff line number Diff line change 1
- import type { PayloadAction } from '@reduxjs/toolkit'
2
1
import { createSlice } from '@reduxjs/toolkit'
3
2
import type { RootState } from '../../app/store.js'
4
3
@@ -37,27 +36,22 @@ export type PollingAppKey = keyof (typeof initialState)['apps']
37
36
export const pollingSlice = createSlice ( {
38
37
name : 'polling' ,
39
38
initialState,
40
- reducers : ( creators ) => {
39
+ reducers : ( create ) => {
41
40
return {
42
- toggleGlobalPolling : creators . reducer ( ( state ) => {
41
+ toggleGlobalPolling : create . reducer ( ( state ) => {
43
42
state . enabled = ! state . enabled
44
43
} ) ,
45
- updatePolling (
46
- state ,
47
- {
48
- payload,
49
- } : PayloadAction < {
50
- app : PollingAppKey
51
- enabled ?: boolean
52
- interval ?: number
53
- } > ,
54
- ) {
44
+ updatePolling : create . reducer < {
45
+ app : PollingAppKey
46
+ enabled ?: boolean
47
+ interval ?: number
48
+ } > ( ( state , { payload } ) => {
55
49
const { app, ...rest } = payload
56
50
state . apps [ app ] = {
57
51
...state . apps [ app ] ,
58
52
...rest ,
59
53
}
60
- } ,
54
+ } ) ,
61
55
}
62
56
} ,
63
57
selectors : {
You can’t perform that action at this time.
0 commit comments