Skip to content

Commit 10dae7b

Browse files
authored
Merge pull request #49 from podium-lib/include-exclude
docs: api docs for new feature in client
2 parents 27a7a1a + a68b036 commit 10dae7b

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

docs/api/layout.md

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,15 +1705,34 @@ layout.client.fooBar.fetch();
17051705

17061706
#### options (required)
17071707

1708-
| option | type | default | required | details |
1709-
| ---------- | --------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
1710-
| uri | `string` | | ✓ | Uri to the manifest of a podlet |
1711-
| name | `string` | | ✓ | Name of the component. This is used to reference the component in your application, and does not have to match the name of the component itself |
1712-
| retries | `number` | `4` | | The number of times the client should retry to settle a version number conflict before terminating. Overrides the `retries` option in the layout constructor |
1713-
| timeout | `number` | `1000` | | Defines how long, in milliseconds, a request should wait before the connection is terminated. Overrides the `timeout` option in the layout constructor |
1714-
| throwable | `boolean` | `false` | | Defines whether an error should be thrown if a failure occurs during the process of fetching a podlet. [See Fallbacks](/docs/guides/fallbacks). |
1715-
| resolveJs | `boolean` | `false` | | Defines whether to resolve relative URIs to absolute URIs for JavaScript assets |
1716-
| resolveCss | `boolean` | `false` | | Defines whether to resolve relative URIs to absolute URIs for CSS assets |
1708+
| option | type | default | required | details |
1709+
| --------- | --------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
1710+
| uri | `string` | | ✓ | Uri to the manifest of a podlet |
1711+
| name | `string` | | ✓ | Name of the component. This is used to reference the component in your application, and does not have to match the name of the component itself |
1712+
| retries | `number` | `4` | | The number of times the client should retry to settle a version number conflict before terminating. Overrides the `retries` option in the layout constructor |
1713+
| timeout | `number` | `1000` | | Defines how long, in milliseconds, a request should wait before the connection is terminated. Overrides the `timeout` option in the layout constructor |
1714+
| throwable | `boolean` | `false` | | Defines whether an error should be thrown if a failure occurs during the process of fetching a podlet. [See Fallbacks](/docs/guides/fallbacks). |
1715+
| excludeBy | `object` | | | Lets you define a set of rules where a `fetch` call will not be resolved if it matches. |
1716+
| includeBy | `object` | | | Inverse of `excludeBy`. Setting both at the same time will throw. |
1717+
1718+
##### `excludeBy` and `includeBy`
1719+
1720+
These options are used by `fetch` to conditionally skip fetching the podlet content based on values on the request. It's an alternative to conditionally fetching podlets in your request handler. Setting both at the same time will throw.
1721+
1722+
Example: exclude a header and footer in a hybrid web view.
1723+
1724+
```js
1725+
import Client from "@podium/client";
1726+
const client = new Client();
1727+
1728+
const footer = client.register({
1729+
uri: "http://footer.site.com/manifest.json",
1730+
name: "footer",
1731+
excludeBy: {
1732+
deviceType: ["hybrid-ios", "hybrid-android"], // when footer.fetch(incoming) is called, if the incoming request has the header `x-podium-device-type: hybrid-ios`, `fetch` will return an empty response.
1733+
},
1734+
});
1735+
```
17171736

17181737
### .client.refreshManifests()
17191738

0 commit comments

Comments
 (0)