# orion.edit.model

An `orion.edit.model` service provides listeners on changes made to the `orion.textview.TextView` that powers the Orion editor.

NOTE: This section is experimental and may change in future versions.

## Service methods

An implementation of `orion.edit.model` may define zero or more functions depending on what event types it gives in its types attribute. For every event type in types, the function with the name `"on" + eventType` will be invoked. For example, a "ModelChanged" event type causes the the provider's onModelChanged function to be invoked.

The functions are always invoked with a single parameter, `event`, containing the event data that was dispatched by the TextView.

## Service attributes

Implementations of `orion.edit.model` must define the following attributes:

types
  `Array` An array of TextView event types that this provider is interested in. When an event of one of these types is dispatched by the TextView, this provider's corresponding function will be invoked. For example, a provider with "ModelChanged" in its types array will have its onModelChanged function invoked whenever the TextView dispatches a `ModelChanged` event.
contentType
  `Array` An array of Content Type IDs that this provider is interested in listening to changes for. The provider will only be notified of events that occur when a file matching one of these content types is being edited.

## Example

See the source code of the orion-codemirror plugin.