---
lang: en
title: 'API docs: context.contextview'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
permalink: /doc/en/lb4/apidocs.context.contextview.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/context](./context.md) &gt; [ContextView](./context.contextview.md)

## ContextView class

`ContextView` provides a view for a given context chain to maintain a live list of matching bindings and their resolved values within the context hierarchy.

This class is the key utility to implement dynamic extensions for extension points. For example, the RestServer can react to `controller` bindings even they are added/removed/updated after the application starts.

`ContextView` is an event emitter that emits the following events: - 'close': when the view is closed (stopped observing context events) - 'refresh': when the view is refreshed as bindings are added/removed - 'resolve': when the cached values are resolved and updated

<b>Signature:</b>

```typescript
export declare class ContextView<T = unknown> extends EventEmitter implements ContextObserver 
```

## Constructors

|  Constructor | Modifiers | Description |
|  --- | --- | --- |
|  [(constructor)(context, filter, comparator)](./context.contextview._constructor_.md) |  | Constructs a new instance of the <code>ContextView</code> class |

## Properties

|  Property | Modifiers | Type | Description |
|  --- | --- | --- | --- |
|  [\_cachedBindings](./context.contextview._cachedbindings.md) |  | <code>Readonly&lt;Binding&lt;T&gt;&gt;[] &#124; undefined</code> |  |
|  [\_cachedValues](./context.contextview._cachedvalues.md) |  | <code>T[] &#124; undefined</code> |  |
|  [bindings](./context.contextview.bindings.md) |  | <code>Readonly&lt;Binding&lt;T&gt;&gt;[]</code> | Get the list of matched bindings. If they are not cached, it tries to find them from the context. |
|  [comparator](./context.contextview.comparator.md) |  | <code>BindingComparator &#124; undefined</code> |  |
|  [context](./context.contextview.context.md) |  | <code>Context</code> |  |
|  [filter](./context.contextview.filter.md) |  | <code>BindingFilter</code> |  |

## Methods

|  Method | Modifiers | Description |
|  --- | --- | --- |
|  [asGetter(session)](./context.contextview.asgetter.md) |  | As a <code>Getter</code> function |
|  [close()](./context.contextview.close.md) |  | Stop listening events from the context |
|  [findBindings()](./context.contextview.findbindings.md) |  | Find matching bindings and refresh the cache |
|  [observe(event, binding)](./context.contextview.observe.md) |  | Listen on <code>bind</code> or <code>unbind</code> and invalidate the cache |
|  [open()](./context.contextview.open.md) |  | Start listening events from the context |
|  [refresh()](./context.contextview.refresh.md) |  | Refresh the view by invalidating its cache |
|  [resolve(session)](./context.contextview.resolve.md) |  | Resolve values for the matching bindings |
|  [singleValue(session)](./context.contextview.singlevalue.md) |  | Get the single value |
|  [values(session)](./context.contextview.values.md) |  | Get the list of resolved values. If they are not cached, it tries to find and resolve them. |


