feat(platform-server): add an API to transfer state from server (#19134)

TransferState provides a shared store that is transferred from the
server to client. To use it import BrowserTransferStateModule from the
client app module and ServerTransferStateModule from the server app
module and TransferState will be available as an Injectable object.

PR Close #19134
This commit is contained in:
Vikram Subramanian
2017-09-11 00:18:55 -07:00
committed by Igor Minar
parent f96142cd7c
commit cfd9ca0d6f
18 changed files with 571 additions and 2 deletions

View File

@ -73,6 +73,7 @@ var specFiles: any =
.concat(glob.sync('@angular/platform-browser/test/security/**/*_spec.js', {cwd: distAll}))
.concat(['/@angular/platform-browser/test/browser/meta_spec.js'])
.concat(['/@angular/platform-browser/test/browser/title_spec.js'])
.concat(['/@angular/platform-browser/test/browser/transfer_state_spec.js'])
.reduce((specFiles: string[], paths: string[]) => specFiles.concat(paths), <string[]>[]);
jasmine.DEFAULT_TIMEOUT_INTERVAL = 100;

View File

@ -6,6 +6,10 @@ export declare class BrowserModule {
}): ModuleWithProviders;
}
/** @experimental */
export declare class BrowserTransferStateModule {
}
/** @experimental */
export declare class By {
static all(): Predicate<DebugElement>;
@ -55,6 +59,9 @@ export declare class HammerGestureConfig {
buildHammer(element: HTMLElement): HammerInstance;
}
/** @experimental */
export declare function makeStateKey<T =
/** @experimental */
export declare class Meta {
constructor(_doc: any);
@ -109,6 +116,11 @@ export interface SafeUrl extends SafeValue {
export interface SafeValue {
}
/** @experimental */
export declare type StateKey<T> = string & {
__not_a_string: never;
};
/** @experimental */
export declare class Title {
constructor(_doc: any);
@ -116,5 +128,15 @@ export declare class Title {
setTitle(newTitle: string): void;
}
/** @experimental */
export declare class TransferState {
get<T>(key: StateKey<T>, defaultValue: T): T;
hasKey<T>(key: StateKey<T>): boolean;
onSerialize<T>(key: StateKey<T>, callback: () => T): void;
remove<T>(key: StateKey<T>): void;
set<T>(key: StateKey<T>, value: T): void;
toJson(): string;
}
/** @stable */
export declare const VERSION: Version;

View File

@ -41,5 +41,9 @@ export declare function renderModuleFactory<T>(moduleFactory: NgModuleFactory<T>
export declare class ServerModule {
}
/** @experimental */
export declare class ServerTransferStateModule {
}
/** @stable */
export declare const VERSION: Version;