diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/shared/workspace/workspace.context.ts b/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/shared/workspace/workspace.context.ts index 0f909ad58d..775cfdda22 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/shared/workspace/workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/workspaces/shared/workspace/workspace.context.ts @@ -1,8 +1,40 @@ +import { BehaviorSubject } from "rxjs"; + +type WorkspaceContextData = { + entityKey: string, + entityType: string, +} + export class UmbWorkspaceContext { - // TODO: Should this use RxJS to be reactive? A store, to hold the props below? + private _data = new BehaviorSubject({ + entityKey: '', + entityType: '', + }); + public readonly data = this._data.asObservable(); - public entityKey = ''; - public entityType = ''; + + public get entityKey() { + return this.getData().entityKey; + } + public set entityKey(value) { + this.update({entityKey:value}); + } + + + public get entityType() { + return this.getData().entityType; + } + public set entityType(value) { + this.update({entityType:value}); + } + + public getData() { + return this._data.getValue(); + } + + public update(data: Partial) { + this._data.next({ ...this._data.getValue(), ...data }); + } } \ No newline at end of file