本文整理匯總了TypeScript中app/store/store.store類的典型用法代碼示例。如果您正苦於以下問題:TypeScript store類的具體用法?TypeScript store怎麽用?TypeScript store使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了store類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: updateLocation
this.$rootScope.$on('$routeUpdate', (evt, data) => {
const angularUrl = this.$location.url();
const state = store.getState();
if (state.location.url !== angularUrl) {
store.dispatch(
updateLocation({
path: this.$location.path(),
query: this.$location.search(),
routeParams: this.$route.current.params,
})
);
}
});
示例2: init
init() {
this.$rootScope.$on('$routeUpdate', (evt, data) => {
const angularUrl = this.$location.url();
const state = store.getState();
if (state.location.url !== angularUrl) {
store.dispatch(
updateLocation({
path: this.$location.path(),
query: this.$location.search(),
routeParams: this.$route.current.params,
})
);
}
});
this.$rootScope.$on('$routeChangeSuccess', (evt, data) => {
store.dispatch(
updateLocation({
path: this.$location.path(),
query: this.$location.search(),
routeParams: this.$route.current.params,
})
);
});
// Listen for changes in redux location -> update angular location
store.subscribe(() => {
const state = store.getState();
const angularUrl = this.$location.url();
const url = locationUtil.stripBaseFromUrl(state.location.url);
if (angularUrl !== url) {
this.$timeout(() => {
this.$location.url(url);
// some state changes should not trigger new browser history
if (state.location.replace) {
this.$location.replace();
}
});
console.log('store updating angular $location.url', url);
}
});
appEvents.on('location-change', (payload: any) => {
const urlWithoutBase = locationUtil.stripBaseFromUrl(payload.href);
if (this.fullPageReloadRoutes.indexOf(urlWithoutBase) > -1) {
this.$window.location.href = payload.href;
return;
}
this.$timeout(() => {
// A hack to use timeout when we're changing things (in this case the url) from outside of Angular.
this.$location.url(urlWithoutBase);
});
});
}
示例3: updateLocation
const onViewPanel = () => {
store.dispatch(
updateLocation({
query: {
panelId: panel.id,
edit: null,
fullscreen: true,
},
partial: true,
})
);
};
示例4:
store.subscribe(() => {
const state = store.getState();
const angularUrl = this.$location.url();
const url = locationUtil.stripBaseFromUrl(state.location.url);
if (angularUrl !== url) {
this.$timeout(() => {
this.$location.url(url);
// some state changes should not trigger new browser history
if (state.location.replace) {
this.$location.replace();
}
});
console.log('store updating angular $location.url', url);
}
});