File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @msw-dev-tool/core " : patch
3
+ ---
4
+
5
+ Remove the temp handler
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ export interface HandlerStoreState {
38
38
getFlattenHandlerById : ( id : string ) => FlattenHandler | undefined ;
39
39
getHandlerBehavior : ( id : string ) => HttpHandlerBehavior | undefined ;
40
40
setHandlerBehavior : ( id : string , behavior : HttpHandlerBehavior ) => void ;
41
+ removeTempHandler : ( id : string ) => void ;
41
42
}
42
43
43
44
export const handlerStore = create < HandlerStoreState > ( ) (
@@ -188,6 +189,20 @@ export const handlerStore = create<HandlerStoreState>()(
188
189
} ) ,
189
190
} ) ;
190
191
} ,
192
+ removeTempHandler : ( id : string ) => {
193
+ const handler = get ( ) . flattenHandlers . find ( ( h ) => h . id === id ) ;
194
+ if ( ! handler ) {
195
+ throw new Error ( `Handler not found for the given id: ${ id } ` ) ;
196
+ }
197
+ if ( handler . type !== "temp" ) {
198
+ throw new Error (
199
+ `Handlers generated from codebase cannot be deleted (id: ${ id } ). You can only disable them.`
200
+ ) ;
201
+ }
202
+ set ( {
203
+ flattenHandlers : get ( ) . flattenHandlers . filter ( ( h ) => h . id !== id ) ,
204
+ } ) ;
205
+ } ,
191
206
} ) ,
192
207
{
193
208
name : STORAGE_KEY ,
You can’t perform that action at this time.
0 commit comments