Created
April 16, 2016 18:52
-
-
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!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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