ViewNavigator class

Manages a stack of views.

Remarks

The top of the stack represents the currently rendered view.

Constructors

(constructor)(handleStackChangedCallback, handleInitializeCallback)

Constructs a new instance of the ViewNavigator class

Properties

currentId

Get the id of the currently rendered View from the top of the View stack

size

Current size of the View stack.

Methods

pop(skipUpdate)

If there is more than one View, pops the top View from the View stack.

BaseAdaptiveCardExtension.setState(), which will also trigger a render.

push(id, skipUpdate)

Pushes a new view to the top of the view stack.

BaseAdaptiveCardExtension.setState(), which will also trigger a render.

register(id, initializer)

Registers a new view.

replace(id, skipUpdate)

Replaces the top view with a new view.

BaseAdaptiveCardExtension.setState(), which will also trigger a render.

Constructor Details

(constructor)(handleStackChangedCallback, handleInitializeCallback)

Constructs a new instance of the ViewNavigator class

constructor(handleStackChangedCallback: (skipUpdate: boolean) => void, handleInitializeCallback: (view: TView) => void);

Parameters

handleStackChangedCallback

(skipUpdate: boolean) => void

handleInitializeCallback

(view: TView) => void

Property Details

currentId

Get the id of the currently rendered View from the top of the View stack

get currentId(): string | undefined;

Property Value

string | undefined

Remarks

If the stack is empty, this will return undefined

size

Current size of the View stack.

get size(): number;

Property Value

number

Method Details

pop(skipUpdate)

If there is more than one View, pops the top View from the View stack.

BaseAdaptiveCardExtension.setState(), which will also trigger a render.

pop(skipUpdate?: boolean): void;

Parameters

skipUpdate

boolean

Whether to skip the update (and re-render) after popping the current View.

Returns

void

push(id, skipUpdate)

Pushes a new view to the top of the view stack.

BaseAdaptiveCardExtension.setState(), which will also trigger a render.

push(id: string, skipUpdate?: boolean): void;

Parameters

id

string

Unique identifier for the view.

skipUpdate

boolean

Whether to skip the update (and re-render) after pushing the new view.

Returns

void

register(id, initializer)

Registers a new view.

register(id: string, initializer: () => TView | Promise<TView>): void;

Parameters

id

string

Unique identifier for the view.

initializer

() => TView | Promise<TView>

Function that returns a new view - or a promise to a new view - which is only called if no view with the id already exists.

Returns

void

Remarks

A View with a given id is only initialized once, and the instance is reused if it is pushed more than once

replace(id, skipUpdate)

Replaces the top view with a new view.

BaseAdaptiveCardExtension.setState(), which will also trigger a render.

replace(id: string, skipUpdate?: boolean): void;

Parameters

id

string

Unique identifier for the view.

skipUpdate

boolean

Whether to skip the update (and re-render) after replacing the current view.

Returns

void