0.36.1 • Published 4 years ago

@narando/event-types v0.36.1

Weekly downloads
86
License
UNLICENSED
Repository
gitlab
Last release
4 years ago

@narando/event-types

Helps handle narando events type safe.

Related packages are @narando/event-consumer and @narando/event-producer.

Getting Started

You need to have nodejs and npm installed.

$ npm install @narando/event-types

Usage

import {
  NarandoEvent,
  ArticleCreatedSoundFileEvent,
  isArticleCreatedSoundFileEvent,
} from "@narando/event-types";

// Use type predicated to select specific events
function handleEvent(event: NarandoEvent) {
  if (isArticleCreatedSoundFileEvent(event)) {
    // event is ArticleCreatedSoundFileEvent
    event.msg.target.soundFileId;
  }

  // event is generic NarandoEvent
}

// Type-safe event handling
function handleArticleCreatedSoundFileEvent(
  event: ArticleCreatedSoundFileEvent
) {}

Development

As this package is part of the toolkit monorepo, please refer to the top-level README to learn about hacking on this package.