Socket
Socket
Sign inDemoInstall

ddd-es-node

Package Overview
Dependencies
4
Maintainers
1
Versions
211
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ddd-es-node

ddd-es-node


Version published
Weekly downloads
1
decreased by-80%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

ddd-es-node

DDD and Event Sourcing primitives for nodejs

Install

npm install ddd-es-node --save

Usage

import { Entity } from 'ddd-es-node';
import { OrderCancelledEvent } from './events';

class Order extends Entity {
  constructor(id) {
    super(id, Entity.CONFIG((self, event) => {
      if(event instanceof OrderCancelledEvent) {
        this.cancelled = true;
      }
    }));
  }
  cancel() {
    if(this.cancelled) {
      throw new Error('Order already cancelled');
    } else {
      this.dispatch(this.id, new OrderCancelledEvent());
    }
  }
}

FAQs

Last updated on 15 Nov 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc