Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Named export createSagaMiddleware added to @redux-saga/core #2399

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/index.js
@@ -1,5 +1,5 @@
export { CANCEL, SAGA_LOCATION } from '@redux-saga/symbols'
export { default } from './internal/middleware'
export { default, createSagaMiddleware } from './internal/middleware'

export { runSaga } from './internal/runSaga'
export { END, isEnd, eventChannel, channel, multicastChannel, stdChannel } from './internal/channel'
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/internal/middleware.js
Expand Up @@ -3,7 +3,7 @@ import { check, assignWithSymbols, createSetContextWarning } from './utils'
import { stdChannel } from './channel'
import { runSaga } from './runSaga'

export default function sagaMiddlewareFactory({ context = {}, channel = stdChannel(), sagaMonitor, ...options } = {}) {
export function createSagaMiddleware({ context = {}, channel = stdChannel(), sagaMonitor, ...options } = {}) {
let boundRunSaga

if (process.env.NODE_ENV !== 'production') {
Expand Down Expand Up @@ -47,3 +47,5 @@ export default function sagaMiddlewareFactory({ context = {}, channel = stdChann

return sagaMiddleware
}

export default createSagaMiddleware
8 changes: 6 additions & 2 deletions packages/core/types/index.d.ts
Expand Up @@ -103,7 +103,11 @@ export interface SagaMonitor {
*
* @param options A list of options to pass to the middleware
*/
export default function createSagaMiddleware<C extends object>(options?: SagaMiddlewareOptions<C>): SagaMiddleware<C>
declare function createSagaMiddleware<C extends object>(options?: SagaMiddlewareOptions<C>): SagaMiddleware<C>

export { createSagaMiddleware }

export default createSagaMiddleware

export interface SagaMiddlewareOptions<C extends object = {}> {
/**
Expand All @@ -129,7 +133,7 @@ export interface SagaMiddlewareOptions<C extends object = {}> {
* If provided, the middleware will use this channel instead of the default `stdChannel` for
* take and put effects.
*/
channel?: MulticastChannel<Action>;
channel?: MulticastChannel<Action>
}

export interface SagaMiddleware<C extends object = {}> extends Middleware {
Expand Down