Skip to content

Commit

Permalink
Release 1.1.0
Browse files Browse the repository at this point in the history
- Add ability to recycle cached results (resolves #1)
- Refactor actionBeforeRoute to accept dynamic action (resolves #2)
- Add actionBeforeLeave (resolves #3)
  • Loading branch information
ClickerMonkey committed Sep 24, 2018
1 parent 0243773 commit 2455b0e
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 16 deletions.
33 changes: 31 additions & 2 deletions dist/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface ActionObject<S, R> {
export interface ActionCache<S, R> {
getKey: (injectee: ActionContext<S, R>, payload: any) => any;
action: Action<S, R>;
onFree?: (result: any) => any;
}
export interface ActionCaches<S, R> {
[key: string]: ActionCache<S, R>;
Expand All @@ -16,18 +17,23 @@ export interface ActionResultCache<S, R> {
getKey?: (injectee: ActionContext<S, R>, payload: any) => any;
getResultKey: (injectee: ActionContext<S, R>, payload: any) => any;
action: Action<S, R>;
onFree?: (result: any) => any;
}
export interface ActionResultCaches<S, R> {
[key: string]: ActionResultCache<S, R>;
}
export interface ActionCacheConditional<S, R> {
isInvalid: (injectee: ActionContext<S, R>, payload: any) => any;
action: Action<S, R>;
onFree?: (result: any) => any;
}
export interface ActionCacheConditionals<S, R> {
[key: string]: ActionCacheConditional<S, R>;
}
export declare type ActionRouteOtherwise = (to: any, from: any, rejectReason: any, store: any, action: any) => any;
export declare type ActionRouteName = string;
export declare type ActionRouteNameCallback = (to: any, from: any, store: any) => string;
export declare type ActionRouteNameInput = ActionRouteName | ActionRouteNameCallback;
export declare type ActionLoadingHandler<S, R> = (injectee: ActionContext<S, R>, loading: boolean) => any;
export declare type ActionLoadingInput<S, R> = string | ActionLoadingHandler<S, R>;
export interface ActionsPluginOptions extends ActionsWatchOptions {
Expand Down Expand Up @@ -111,13 +117,36 @@ export declare function actionsDestroyCache(): void;
* </script>
* ```
*
* @param action The action to dispatch on the store and watch for.
* @param actionInput The action to dispatch on the store and wait for.
* @param getOtherwise Where to go if the dispatched action is a reject.
*/
export declare function actionBeforeRoute(action: string, getOtherwise?: ActionRouteOtherwise): {
export declare function actionBeforeRoute(actionInput: ActionRouteNameInput, getOtherwise?: ActionRouteOtherwise): {
beforeRouteEnter: (to: any, from: any, next: any) => void;
beforeRouteUpdate: (to: any, from: any, next: any) => void;
};
/**
* Dispatches an action in the store and optionally waits for the action to
* finish before leaving the current component (see `beforeRouteLeave` in
* `vue-router`).
*
* ```javascript
* // MyPage.vue
* <script>
* import { actionBeforeLeave } from 'vuex-router-actions'
*
* export default {
* ...actionBeforeLeave('unloadMyPage')
* }
* </script>
* ```
*
* @param actionInput The action to dispatch on the store and optionally wait for.
* @param waitForFinish If the unload action should finish before the component
* is left.
*/
export declare function actionBeforeLeave(actionInput: ActionRouteNameInput, waitForFinish?: boolean): {
beforeRouteLeave: (to: any, from: any, next: any) => void;
};
/**
* Allows you to pass the results of a dispath through this function and whether
* or not it resolves or rejects it won't stop from proceeding. This happens by
Expand Down
2 changes: 1 addition & 1 deletion dist/vuex-router-actions.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vuex-router-actions",
"version": "1.0.0",
"version": "1.1.0",
"author": "Philip Diffenderfer",
"description": "A library for loading views with actions, including caching, permissions, loading, and logging.",
"license": "MIT",
Expand Down
Loading

0 comments on commit 2455b0e

Please sign in to comment.