# Examples

{% hint style="info" %}
Note that some event timeline features are in [Early Access](https://github.com/sentiance/v4-docs/blob/main/important-topics/sdk/api-reference/react-native/event-timeline/broken-reference/README.md), specifically the ones related to venue-type determination.
{% endhint %}

### Install the module

Run the following command to install the module (make sure to install the **core** module beforehand):

```bash
npm i @sentiance-react-native/event-timeline
```

### Import the module

```javascript
import SentianceEventTimeline from "@sentiance-react-native/event-timeline";
```

#### Get timeline updates

```javascript
const after = new Date();

// returns Promise<Event[]>
const events = await SentianceEventTimeline.getTimelineUpdates(after.getTime());
```

#### Get timeline events

```javascript
const from = new Date(0); // 01/01/1970
const to = new Date(2 ** 31 * 1000);

// returns Promise<Event[]>
const events = await SentianceEventTimeline.getTimelineEvents(
    from.getTime(), to.getTime());
```

#### Get a single timeline event

```javascript
const eventId = 'event_id';

// Returns an Event object if found, undefined otherwise.
const event = await SentianceEventTimeline.getTimelineEvent(eventId);
```

#### Listen to timeline updates

```javascript
const subscription = await SentianceEventTimeline.addTimelineUpdateListener(
  event => {
    // Do something with the event received
});

// Don't forget to unsubscribe, typically in componentWillUnmount
subscription.remove();
```

You can find a reference to all the types mentioned on this page [here](https://github.com/sentiance/react-native-sentiance/blob/main/packages/event-timeline/lib/index.d.ts).
