Skip to content

Commit

Permalink
Merge branch 'command-docs'
Browse files Browse the repository at this point in the history
  • Loading branch information
LFDM committed Aug 2, 2017
2 parents d7982fa + a6a067f commit e6e0dbd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/advanced/Invalidation.md
Expand Up @@ -33,7 +33,7 @@ const config = {
ttl: 300,
api: gameApi,
invalidates: ['topList'],
invalidatesOn: ['UPDATE'] // Default: ['CREATE', 'UPDATE', 'DELETE']
invalidatesOn: ['UPDATE'] // Default: ['CREATE', 'UPDATE', 'DELETE', 'COMMAND']
}
};
```
Expand Down
2 changes: 1 addition & 1 deletion docs/advanced/Plugins.md
Expand Up @@ -126,7 +126,7 @@ following shape:

```javascript
{
operation: 'CREATE' | 'READ' | 'UPDATE' | 'DELETE' | 'NO_OPERATION',
operation: 'CREATE' | 'READ' | 'UPDATE' | 'DELETE' | 'COMMAND' | 'NO_OPERATION',
entity: EntityName,
apiFn: ApiFunctionName,
args: Any[] | null
Expand Down
4 changes: 2 additions & 2 deletions docs/basics/Configuration.md
Expand Up @@ -6,7 +6,7 @@ There are a handful optional options to configure Ladda. In a minimal configurat

* **ttl**: How long to cache in seconds. Default is `300` seconds.

* **invalidatesOn**: `[Operation]` where `Operation := "CREATE" | "READ" | "UPDATE" | "DELETE" | "NO_OPERATION"`. Default is `["CREATE", "UPDATE", "DELETE"]`.
* **invalidatesOn**: `[Operation]` where `Operation := "CREATE" | "READ" | "UPDATE" | "DELETE" | "COMMAND" | "NO_OPERATION"`. Default is `["CREATE", "UPDATE", "DELETE", "COMMAND"]`.

* **invalidates**: `[EntityName]` where EntityName is the key of your EntityConfig. By default an empty list `[]`.

Expand All @@ -19,7 +19,7 @@ There are a handful optional options to configure Ladda. In a minimal configurat

## Method Configuration

* **operation**: `"CREATE" | "READ" | "UPDATE" | "DELETE" | "NO_OPERATION"`. Default is `"NO_OPERATION"`.
* **operation**: `"CREATE" | "READ" | "UPDATE" | "DELETE" | "COMMAND" | "NO_OPERATION"`. Default is `"NO_OPERATION"`.

* **invalidates**: `[ApiFunctionName]` where ApiFunctionName is a name of another function in the same api (see Entity Configuration - api). By default this is the empty list `[]`.

Expand Down
4 changes: 3 additions & 1 deletion docs/basics/Operations.md
Expand Up @@ -6,10 +6,12 @@ Ladda shows its whole potential in a create, read, update & delete application.

* **READ**: An API call which returns an EntityValue, or a list of EntityValues (eg. a user or list of users).

* **UPDATE**: Takes the updated EntityValue as the first argument (eg. a user). No assumptions on what is returned by the server are made.
* **UPDATE**: Takes the updated EntityValue as the first argument (eg. a user). No assumptions on what is returned by the server are made. The first argument provided is used to update the cache.

* **DELETE**: Takes an ID as the first argument. No assumptions on what is returned by the server are made.

* **COMMAND**: Takes any arguments and expects an updated EntityValue, or a list of them, as return value. This return value is used to update the cache.

* **NO_OPERATION** : When no operation is specified Ladda will not do anything by default. However, you can still use the invalidation logic of Ladda, see EntityConfig. No assumptions on what is returned by the server are made.

An example of how a function of operation CREATE might look is:
Expand Down
2 changes: 1 addition & 1 deletion src/builder.js
Expand Up @@ -62,7 +62,7 @@ const setEntityConfigDefaults = ec => {
return {
ttl: 300,
invalidates: [],
invalidatesOn: ['CREATE', 'UPDATE', 'DELETE'],
invalidatesOn: ['CREATE', 'UPDATE', 'DELETE', 'COMMAND'],
enableDeduplication: true,
...ec
};
Expand Down

0 comments on commit e6e0dbd

Please sign in to comment.