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 {
3838 getFlattenHandlerById : ( id : string ) => FlattenHandler | undefined ;
3939 getHandlerBehavior : ( id : string ) => HttpHandlerBehavior | undefined ;
4040 setHandlerBehavior : ( id : string , behavior : HttpHandlerBehavior ) => void ;
41+ removeTempHandler : ( id : string ) => void ;
4142}
4243
4344export const handlerStore = create < HandlerStoreState > ( ) (
@@ -188,6 +189,20 @@ export const handlerStore = create<HandlerStoreState>()(
188189 } ) ,
189190 } ) ;
190191 } ,
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+ } ,
191206 } ) ,
192207 {
193208 name : STORAGE_KEY ,
You can’t perform that action at this time.
0 commit comments