Skip to content

Instantly share code, notes, and snippets.

@Killavus
Created April 16, 2016 18:52
Show Gist options
  • Select an option

  • Save Killavus/99f6cc3107a86100ffa7941cdcffd45d to your computer and use it in GitHub Desktop.

Select an option

Save Killavus/99f6cc3107a86100ffa7941cdcffd45d to your computer and use it in GitHub Desktop.
Products List App example in Hexagonal Architecture - two features for the same UI adapter!
// Here are objects that provides use case and ports:
import ProcessingCustomerCart from "./ProcessingCustomerCart";
import RequestingCustomerCare from "./RequestingCustomerCare";
// Adapters:
import ProductsListUI from "./ProductsListUI";
import AppRouter from "./AppRouter";
import ErrorsUI from "./ErrorsUI";
import CartBackend from "./CartBackend";
import CustomerCareBackend from "./CustomerCareBackend"
import EventBus from "eventing-bus";
const ProductsListApp = () => {
const cartUseCase = ProcessingCustomerCart.UseCase();
const cartPorts = ProcessingCustomerCart.Ports(cartUseCase, ui, AppRouter, EventBus, ErrorsUI);
const cartBackend = CartBackend();
const careUseCase = RequestingCustomerCare.UseCase();
const careBackend = CustomerCareBackend();
const carePorts = RequestingCustomerCare.Ports(careUseCase, ui, careBackend);
const ui = ProductsListUI(EventBus);
return {
start(domElement) {
ui.render(domElement, () => {
backend.load().then(items => {
EventBus.publish('cartLoaded', items);
});
});
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment