mswjs / msw

Industry standard API mocking for JavaScript.
https://mswjs.io
MIT License
15.97k stars 519 forks source link

Addition of Boundary() to setupServer() in react-native with help of AsyncLocalStorage alternative in RN #2188

Closed pratyushbh closed 4 months ago

pratyushbh commented 5 months ago

Scope

Adds a new behavior

Compatibility

Feature description

To add a Boundary() method to the setupServer() method in React native to isolate the behaviour of network just like in nodeJS ,since async_hook is not available in react-native, there's no AsyncLocalStorage() in react native like node.js, but there are some async local storage packages in react native that we can use or something else.

kettanaito commented 4 months ago

Hi, @pratyushbh. Thanks for raising this.

I would love to add server.boundary() to React Native but it requires the AsyncLocalStorage API to work. There is no means to implement that API manually. It integrates into the event loop (and internal Node.js hooks) and cannot be provided from the userland.

We need to wait until React Native adds support for AsyncLocalStorage officially.