You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create an instance of Barricade with the help of the `createBarricade` function along with an array of `RequestConfig` as its function argument.
40
+
Create an instance of Barricade with the help of the `createBarricade` function. While calling this function, you can pass an array of `RequestConfig`(optional) to register the request configs. You can also register a request config later by making use of `registerRequest` method on the barricade instance.
41
41
42
42
**:warning: Make sure to do this in index.js so that you can start Barricade before hitting any API.**
const requestConfig = []; // Array of RequestConfigs for all the APIs that needs to be mocked
47
+
const requestConfig = []; //Optional: Array of RequestConfigs for all the APIs that needs to be mocked
48
48
const barricade =createBarricade(requestConfig);
49
49
barricade.start(); // Start the Barricade
50
50
@@ -76,7 +76,25 @@ const App = () => {
76
76
77
77
**3. Create RequestConfigs**
78
78
79
-
Create a `RequestConfig` for each API you want to mock. Then, add these to the list of request configs shown in Step 1.
79
+
Create a `RequestConfig` for each API you want to mock. Then, add these to the list of request configs shown in Step 1 or register them individually by calling the `registerRequest` method as shown below.
**:warning: Make sure to call the `registerRequest` method only after barricade instance is created.**
89
+
90
+
In case you want to unregister a config programmatically, you can do this by calling the `unregisterRequest` method similar to the registerRequest method.
@@ -86,6 +104,7 @@ Create a `RequestConfig` for each API you want to mock. Then, add these to the l
86
104
|**`pathEvaluation`**| Data used to identify the current API triggered from the list of RequestConfigs. |`PathEvaluation`|
87
105
|**`responseHandler`**| List of mocked responses the current API can return with. By default, the first response from the list is selected. |`ResponseHandler[]`|
88
106
|**`delay`**| The time (in milliseconds) Barricade needs to wait before responding with the mocked response. This is optional and by default it's `400`. |`number` / `undefined`|
107
+
|**`disabled`**| Boolean used to enable/disable mocking of current API. This is optional and by default it's `undefined`. |`boolean` / `undefined`|
Barricade comes packaged with an in-app interface that allows you to select the network responses at runtime. For this to be visible, you need to add the `BarricadeView` mentioned in Step 2 under **Usage**.
With this in place and the device shaken, you'll be able to see an option for `Barricade` in React Native's developer menu. On tapping the `Barricade` option, you’ll be redirected to a screen with the list of mocked APIs.
@@ -186,7 +205,8 @@ const App = () => {
186
205
```
187
206
188
207
**Note:** In BarricadeView, apart from changing the selected response for any of the listed APIs, we can also:
189
-
- Disable/Enable Barricade. This will stop/start mocking API calls and lets you check the app with the actual/mocked API responses at runtime.
208
+
- Disable/Enable Barricade. This will stop/start mocking all the registered API calls and lets you check the app with the actual/mocked API responses at runtime.
209
+
- Disable/Enable API Mock. This will stop/start mocking the current API calls and lets you check the app with the actual/mocked API response at runtime.
190
210
- Reset all the changes done to the list of selected responses.
0 commit comments