/event-coiler

🐍 Event Coiler is a helper that is used to provide structure to you application events.

Primary LanguageTypeScriptMIT LicenseMIT

Event Coiler snake coiled

All Contributors Build Status semantic-release

The Problem

You need to provide structure, definition, and reuse around events that happen throughout an application. You need the ability to configure with any package or internal solution also.

The Solution

Use Event Coiler to enable structure, defintion, and reuse around your events. This is the solution that helped me create structure, defintion, and reuse around Google Analytic Event's. With providing proper definition, the business is able to make sense of each event that's logged.

Usage

Basic usage to how you can get started coiling your events!

import coiler from 'event-coiler'

// Event interaction config. You probably want this in it's own file `interactions.config.js`
const config = `
  {
    "Dropdown": {
      "clicked": {
        "opened": "opened dropdown",
        "closed": "closed dropdown",
        "updated": "{{item}} was updated to {{uppercase(updated)}}",
      }
    }
  }
`

const gaCoilerSetup = new Coiler({
  emitter: (args) => {
    console.log(args.value) // todo list was updated to CLEAN ROOM
    console.log(args.emitter) // { ns: 'Dropdown.clicked' params: { item: 'todo list', updated: 'clean room' }
  },
  config,
  interpolation: {
    uppercase(value) {
      return value.toUpperCase()
    }
  },
  debug: true,
})

gaCoilerSetup.e('Dropdown.clicked', { item: 'todo list' updated: 'clean room' }) // todo list was updated to CLEAN ROOM

Inspiration

After my first implementation, I found out this was very similar to i18next. Then I used it to help pave the path for Even Coiler.

Other Solutions

  • i18next -- potential solution, but it's rather focused on translation.

Contributors

Thanks goes to these wonderful people (emoji key):


Jon Major

💻 💡 📖

This project follows the all-contributors specification. Contributions of any kind welcome!