Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a
DB
example that contains a number of tables each of which have rows that link to each other. This uses the ability to link anywhere in the store to create a factory method that creates entities elswhere in the store.In this example, the
Blog
record has a reference to aPerson
which is the author. The factory for author attribute of a blog, creates that person in the database, and then returns that person.It isn't just enough to be able to link to entitities from across a
store. You also need to be able to create them in concert with each
other. This presents a unique difficulty in microstates where every
transition is chained off of an "owner" object. How then, do you
operate on objets that might not share a common ancestor?
The answer is to introduce a new primitive: the transaction. This
allows you to pass as many microstates into a transaction as you want,
and with each operation in the transaction, the atom is kept in sync
so that each microstate in a transaction is talking about the same
universe. So, for example, as part of the blog creation process, we
want to first create a person and then a assign that person to the
blog's s author, we need to call create on the people table, and
then set the relationship on the person.
Each transaction has a subject and any number of members, that will be
kept in sync for the operation wich is implemented using the monadic
flatMap
operator. E.g.this will take the
atom
fromsubject
and use it as the basis forall participants in the transaction. In this case
other
, andyetAnother
. So that when we flatMap, all of them are operatingagainst the same data.
Also, every participant in the transaction is scoped to itself as
owner, so that subject.transition() will return subject.
While rock-solid, this makes for an awkward API, so we'll still need
to find out how to do the interior design to make it more
pleasant. Still, I think that can come later.