@fastkit/vue-utils
Advanced tools
Comparing version 0.6.28 to 0.6.30
@@ -740,2 +740,30 @@ 'use strict'; | ||
} | ||
watchRoute(cb, options) { | ||
let stoped = false; | ||
let autoStop = options && options.autoStop; | ||
if (autoStop == null) { | ||
autoStop = true; | ||
} | ||
const stopHandle = vue.watch(this.router.currentRoute, (currentRoute, oldValue, onInvalidate) => { | ||
if (stoped) | ||
return; | ||
if (autoStop) { | ||
vue.nextTick(() => { | ||
if (stoped) | ||
return; | ||
cb(currentRoute, oldValue, onInvalidate); | ||
}); | ||
} | ||
else { | ||
cb(currentRoute, oldValue, onInvalidate); | ||
} | ||
}, options); | ||
if (autoStop) { | ||
vue.onBeforeUnmount(() => { | ||
stoped = true; | ||
stopHandle(); | ||
}); | ||
} | ||
return stopHandle; | ||
} | ||
get transitioningTo() { | ||
@@ -742,0 +770,0 @@ return this.state.transitioningTo; |
@@ -740,2 +740,30 @@ 'use strict'; | ||
} | ||
watchRoute(cb, options) { | ||
let stoped = false; | ||
let autoStop = options && options.autoStop; | ||
if (autoStop == null) { | ||
autoStop = true; | ||
} | ||
const stopHandle = vue.watch(this.router.currentRoute, (currentRoute, oldValue, onInvalidate) => { | ||
if (stoped) | ||
return; | ||
if (autoStop) { | ||
vue.nextTick(() => { | ||
if (stoped) | ||
return; | ||
cb(currentRoute, oldValue, onInvalidate); | ||
}); | ||
} | ||
else { | ||
cb(currentRoute, oldValue, onInvalidate); | ||
} | ||
}, options); | ||
if (autoStop) { | ||
vue.onBeforeUnmount(() => { | ||
stoped = true; | ||
stopHandle(); | ||
}); | ||
} | ||
return stopHandle; | ||
} | ||
get transitioningTo() { | ||
@@ -742,0 +770,0 @@ return this.state.transitioningTo; |
@@ -28,3 +28,3 @@ import { BaseTransitionProps } from 'vue'; | ||
import type { RouteLocationNormalized } from 'vue-router'; | ||
import { RouteLocationNormalizedLoaded } from 'vue-router'; | ||
import type { RouteLocationNormalizedLoaded } from 'vue-router'; | ||
import { RouteLocationRaw } from 'vue-router'; | ||
@@ -45,2 +45,5 @@ import type { Router } from 'vue-router'; | ||
import type { VNodeTypes } from '@vue/runtime-core'; | ||
import { WatchCallback } from 'vue'; | ||
import { WatchOptions } from 'vue'; | ||
import { WatchStopHandle } from 'vue'; | ||
@@ -200,2 +203,5 @@ export declare const BODY_SCROLL_LOCK_ATTRIBUTE = "data-body-scroll-lock"; | ||
get currentRoute(): RouteLocationNormalizedLoaded; | ||
watchRoute<Immediate extends Readonly<boolean> = false>(cb: WatchCallback<RouteLocationNormalizedLoaded, Immediate extends true ? RouteLocationNormalizedLoaded | undefined : RouteLocationNormalizedLoaded>, options?: WatchOptions<Immediate> & { | ||
autoStop?: boolean; | ||
}): WatchStopHandle; | ||
get transitioningTo(): _RouteLocationBase | null; | ||
@@ -202,0 +208,0 @@ get transitioning(): LocationTransitioning | null; |
@@ -1,2 +0,2 @@ | ||
import { Comment, Text, computed, BaseTransition, h, Transition, onBeforeMount, onBeforeUnmount, reactive } from 'vue'; | ||
import { Comment, Text, computed, BaseTransition, h, Transition, onBeforeMount, onBeforeUnmount, reactive, watch, nextTick } from 'vue'; | ||
import { RouterLink } from 'vue-router'; | ||
@@ -736,2 +736,30 @@ import { isObjectEqual, IN_WINDOW, addTransitionendEvent, pushDynamicStyle, debounce } from '@fastkit/helpers'; | ||
} | ||
watchRoute(cb, options) { | ||
let stoped = false; | ||
let autoStop = options && options.autoStop; | ||
if (autoStop == null) { | ||
autoStop = true; | ||
} | ||
const stopHandle = watch(this.router.currentRoute, (currentRoute, oldValue, onInvalidate) => { | ||
if (stoped) | ||
return; | ||
if (autoStop) { | ||
nextTick(() => { | ||
if (stoped) | ||
return; | ||
cb(currentRoute, oldValue, onInvalidate); | ||
}); | ||
} | ||
else { | ||
cb(currentRoute, oldValue, onInvalidate); | ||
} | ||
}, options); | ||
if (autoStop) { | ||
onBeforeUnmount(() => { | ||
stoped = true; | ||
stopHandle(); | ||
}); | ||
} | ||
return stopHandle; | ||
} | ||
get transitioningTo() { | ||
@@ -738,0 +766,0 @@ return this.state.transitioningTo; |
{ | ||
"name": "@fastkit/vue-utils", | ||
"version": "0.6.28", | ||
"version": "0.6.30", | ||
"description": "@fastkit/vue-utils", | ||
@@ -34,7 +34,7 @@ "buildOptions": { | ||
"dependencies": { | ||
"@fastkit/body-scroll-lock": "0.6.28", | ||
"@fastkit/visibility": "0.6.28", | ||
"@fastkit/keybord": "0.6.28", | ||
"@fastkit/helpers": "0.6.28" | ||
"@fastkit/body-scroll-lock": "0.6.30", | ||
"@fastkit/visibility": "0.6.30", | ||
"@fastkit/keybord": "0.6.30", | ||
"@fastkit/helpers": "0.6.30" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
107231
3035
+ Added@fastkit/body-scroll-lock@0.6.30(transitive)
+ Added@fastkit/helpers@0.6.30(transitive)
+ Added@fastkit/keybord@0.6.30(transitive)
+ Added@fastkit/tiny-logger@0.6.30(transitive)
+ Added@fastkit/visibility@0.6.30(transitive)
- Removed@fastkit/body-scroll-lock@0.6.28(transitive)
- Removed@fastkit/helpers@0.6.28(transitive)
- Removed@fastkit/keybord@0.6.28(transitive)
- Removed@fastkit/tiny-logger@0.6.28(transitive)
- Removed@fastkit/visibility@0.6.28(transitive)
Updated@fastkit/helpers@0.6.30
Updated@fastkit/keybord@0.6.30
Updated@fastkit/visibility@0.6.30