Skip to content

Commit

Permalink
Update context examples
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdover committed Oct 8, 2019
1 parent 4f77267 commit 981432f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,17 @@ export interface VizRenderContext {
}

export type VizRenderer = (context: VizRenderContext, domElement: HTMLElement) => () => void;
// When a renderer is bound via `contextContainer.createHandler` this is the type that will be returned.
type BoundVizRenderer = (domElement: HTMLElement) => () => void;

class VizRenderingPlugin {
private readonly vizRenderers = new Map<string, ((domElement: HTMLElement) => () => void)>();
private readonly contextContainer?: IContextContainer<VizRenderer>;
private readonly vizRenderers = new Map<string, BoundVizRenderer>();

constructor(private readonly initContext: PluginInitializerContext) {}

setup(core) {
this.contextContainer = core.context.createContextContainer<
VizRenderContext,
ReturnType<VizRenderer>,
[HTMLElement]
>();
this.contextContainer = core.context.createContextContainer();

return {
registerContext: this.contextContainer.registerContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,17 @@ export interface VizRenderContext {
}

export type VizRenderer = (context: VizRenderContext, domElement: HTMLElement) => () => void;
// When a renderer is bound via `contextContainer.createHandler` this is the type that will be returned.
type BoundVizRenderer = (domElement: HTMLElement) => () => void;

class VizRenderingPlugin {
private readonly vizRenderers = new Map<string, ((domElement: HTMLElement) => () => void)>();
private readonly contextContainer?: IContextContainer<VizRenderer>;
private readonly vizRenderers = new Map<string, BoundVizRenderer>();

constructor(private readonly initContext: PluginInitializerContext) {}

setup(core) {
this.contextContainer = core.context.createContextContainer<
VizRenderContext,
ReturnType<VizRenderer>,
[HTMLElement]
>();
this.contextContainer = core.context.createContextContainer();

return {
registerContext: this.contextContainer.registerContext,
Expand Down
11 changes: 5 additions & 6 deletions src/core/public/context/context_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,17 @@ export class ContextService {
* }
*
* export type VizRenderer = (context: VizRenderContext, domElement: HTMLElement) => () => void;
* // When a renderer is bound via `contextContainer.createHandler` this is the type that will be returned.
* type BoundVizRenderer = (domElement: HTMLElement) => () => void;
*
* class VizRenderingPlugin {
* private readonly vizRenderers = new Map<string, ((domElement: HTMLElement) => () => void)>();
* private readonly contextContainer?: IContextContainer<VizRenderer>;
* private readonly vizRenderers = new Map<string, BoundVizRenderer>();
*
* constructor(private readonly initContext: PluginInitializerContext) {}
*
* setup(core) {
* this.contextContainer = core.context.createContextContainer<
* VizRenderContext,
* ReturnType<VizRenderer>,
* [HTMLElement]
* >();
* this.contextContainer = core.context.createContextContainer();
*
* return {
* registerContext: this.contextContainer.registerContext,
Expand Down
11 changes: 5 additions & 6 deletions src/core/server/context/context_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,17 @@ export class ContextService {
* }
*
* export type VizRenderer = (context: VizRenderContext, domElement: HTMLElement) => () => void;
* // When a renderer is bound via `contextContainer.createHandler` this is the type that will be returned.
* type BoundVizRenderer = (domElement: HTMLElement) => () => void;
*
* class VizRenderingPlugin {
* private readonly vizRenderers = new Map<string, ((domElement: HTMLElement) => () => void)>();
* private readonly contextContainer?: IContextContainer<VizRenderer>;
* private readonly vizRenderers = new Map<string, BoundVizRenderer>();
*
* constructor(private readonly initContext: PluginInitializerContext) {}
*
* setup(core) {
* this.contextContainer = core.context.createContextContainer<
* VizRenderContext,
* ReturnType<VizRenderer>,
* [HTMLElement]
* >();
* this.contextContainer = core.context.createContextContainer();
*
* return {
* registerContext: this.contextContainer.registerContext,
Expand Down

0 comments on commit 981432f

Please sign in to comment.