Skip to content

Commit 4c9b62e

Browse files
committed
Reuse assign with @__PURE__ annotations added
1 parent 2c8b095 commit 4c9b62e

File tree

1 file changed

+18
-10
lines changed
  • packages/toolkit/src/listenerMiddleware

1 file changed

+18
-10
lines changed

packages/toolkit/src/listenerMiddleware/index.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ const getListenerEntryPropsFrom = (options: FallbackAddListenerOptions) => {
217217

218218
/** Accepts the possible options for creating a listener, and returns a formatted listener entry */
219219
export const createListenerEntry: TypedCreateListenerEntry<unknown> =
220-
Object.assign(
220+
/* @__PURE__ */ assign(
221221
(options: FallbackAddListenerOptions) => {
222222
const { type, predicate, effect } = getListenerEntryPropsFrom(options)
223223

@@ -282,21 +282,29 @@ const safelyNotifyError = (
282282
/**
283283
* @public
284284
*/
285-
export const addListener = Object.assign(createAction(`${alm}/add`), {
286-
withTypes: () => addListener,
287-
}) as unknown as TypedAddListener<unknown>
285+
export const addListener = /* @__PURE__ */ assign(
286+
/* @__PURE__ */ createAction(`${alm}/add`),
287+
{
288+
withTypes: () => addListener,
289+
},
290+
) as unknown as TypedAddListener<unknown>
288291

289292
/**
290293
* @public
291294
*/
292-
export const clearAllListeners = createAction(`${alm}/removeAll`)
295+
export const clearAllListeners = /* @__PURE__ */ createAction(
296+
`${alm}/removeAll`,
297+
)
293298

294299
/**
295300
* @public
296301
*/
297-
export const removeListener = Object.assign(createAction(`${alm}/remove`), {
298-
withTypes: () => removeListener,
299-
}) as unknown as TypedRemoveListener<unknown>
302+
export const removeListener = /* @__PURE__ */ assign(
303+
/* @__PURE__ */ createAction(`${alm}/remove`),
304+
{
305+
withTypes: () => removeListener,
306+
},
307+
) as unknown as TypedRemoveListener<unknown>
300308

301309
const defaultErrorHandler: ListenerErrorHandler = (...args: unknown[]) => {
302310
console.error(`${alm}/error`, ...args)
@@ -346,7 +354,7 @@ export const createListenerMiddleware = <
346354
return insertEntry(entry)
347355
}) as AddListenerOverloads<any>
348356

349-
Object.assign(startListening, {
357+
assign(startListening, {
350358
withTypes: () => startListening,
351359
})
352360

@@ -374,7 +382,7 @@ export const createListenerMiddleware = <
374382
return !!entry
375383
}
376384

377-
Object.assign(stopListening, {
385+
assign(stopListening, {
378386
withTypes: () => stopListening,
379387
})
380388

0 commit comments

Comments
 (0)