-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat; add factory method for extensions (#7218)
- Loading branch information
1 parent
29f626f
commit 6bac6f5
Showing
3 changed files
with
52 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
"@vue-storefront/middleware": minor | ||
--- | ||
|
||
[ADDED] Added factory function for the extension API. Previously the extension API was an object with a set of methods. Now it can be created using a factory function the same way as the base API. | ||
|
||
Previously only object was allowed: | ||
|
||
```ts | ||
export const extension: ApiClientExtension = { | ||
name: "extension", | ||
extendApiMethods: { | ||
...extendedMethods, //methods as an object | ||
}, | ||
}; | ||
``` | ||
|
||
Now you can either use an object or a factory function: | ||
|
||
```ts | ||
export const extension: ApiClientExtension = { | ||
name: "extension", | ||
// methods as a factory function with injected config object | ||
extendApiMethods: ({ config }) => { | ||
return createMyMethods(config); | ||
}, | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters