This is a small repository that I'm using to trial various javascript concepts. The primary goal is to follow a more functional approach to where appropriate.
Tests will live under tests in the related directory
A pass at understanding and implementing something with monads.
The first is my pass at a redux style store. It initially started as a functional observer pattern but then ended up being a redux-style store with observers
I wanted to write a simple event store with 2 features around projection. Either wait until all projections have completed successfully before returning or fire them in the next tick immediately returning to the caller.
I feel waiting for projections to complete saves multiple client requests/polling. An API user will typically make a request and want to see the result or the action. Waiting for projections will allow this.
This is a simple express app that ties the event store and the redux style store together.
It uses the events store to save Tasks
to a database and has a store that the projections
will write to. The state of the store is returned to the user after projections have been made.
To start:
- run
bin/setup-env.sh
- run
yarn start:app
- Open your favourite API tool (curl/postman/insomnia?)
- post to
localhost:8001/tasks
an event of the shape{ task: 'my sweet task' }
- Read the response
A simple create-react-app client that will let you create/delete tasks using the event sourced app above.
To start in dev mode:
- Run the
/app
above - In a new tab go to /app/tasks-ui
- run
yarn dev
- Follow the prompts on screen and profit!
In an effort to greater develop my understanding of events and functional programming I've created an emitter that does not store any local state. The goal is to use a recursive approach to maintain state.
Using the functional emitter, and the state monad from the helpers (on further learning this is not actually a state monad. Further readings required), this is a simple application that prompts and adds items to a list. Events are emitted when an item is added and on quit.