-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve: demo and README #15
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I loved reading this README, I just found some nit-picking things that we might want to change before we merge this PR. Very pleasant read, keep it up @vadymmarkov 🚀
### Command execution | ||
|
||
The first step is to declare a command. Your command type has to conform to | ||
`Aftermath.Command` protocol and the `Output` type must be implicitly specified. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From:
The first step is to declare a command. Your command type has to conform to
Aftermath.Command
protocol and theOutput
type must be implicitly specified.
To:
The first step is to declare a command. Your command type has to conform to the
Aftermath.Command
protocol and theOutput
type must be implicitly specified.
`Aftermath.Command` protocol and the `Output` type must be implicitly specified. | ||
|
||
Let's say we want to fetch a list of books from some untrusted resource and | ||
correct typos in titles and author names 🤓. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this part 😁
``` | ||
|
||
**Note** that any type can play a role of `Output`, so if we want to add a date | ||
to our `BookUpdateCommand` it could look like the following: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From:
Note that any type can play a role of
Output
, so if we want to add a date
to ourBookUpdateCommand
it could look like the following:
To:
Note that any type can play the role of
Output
, so if we want to add a date
to ourBookUpdateCommand
it could look like the following:
|
||
### Command handling | ||
|
||
Command is an intention that needs to be translated into action by handler. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From:
Command is an intention that needs to be translated into action by handler.
To:
Command is an intention that needs to be translated into an action by a handler.
Command handler is responsible for publishing events to notify about results of | ||
the operation it performs. Command handler type has to conform to | ||
`Aftermath.CommandHandler` protocol that needs to know about the command type | ||
it will work with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Command handler is responsible for publishing events to notify about results of
the operation it performs. Command handler type has to conform to
Aftermath.CommandHandler
protocol that needs to know about the command type
it will work with:The command handler is responsible for publishing events to notify about results of
the operation it performs. The command handlers type has to conform to
Aftermath.CommandHandler
protocol, that needs to know about the command type
it will work with:
already an output itself, so the only thing you want to do is notify all | ||
subscribers that something happened in the system, and they will react | ||
accordingly. In this sense it's closer to a type-safe alternative to | ||
`NSNotification`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From:
Fact works like notification with no async operations involved. It could
be used when there is no need to have a handler and generate an output. Fact is
already an output itself, so the only thing you want to do is notify all
subscribers that something happened in the system, and they will react
accordingly. In this sense it's closer to a type-safe alternative to
NSNotification
.
To:
Fact works like notification, with no async operations involved. It can
be used when there is no need for a handler to generate an output. Fact is an
output itself, so the only thing you want to do is notify all
subscribers that something happened in the system, and they will react
accordingly. In this sense it's closer to a type-safe alternative to
NSNotification
.
executed command in **Command Middleware**, or do appropriate operation in | ||
**Event Middleware** before the published event is received by its reactions. | ||
It's handy for logging, crash reporting, aborting particular commands or | ||
events, etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From:
Middleware is a layer where commands and events could be intercepted before
the moment they reach listeners. It means you can modify/cancel/extend the
executed command in Command Middleware, or do appropriate operation in
Event Middleware before the published event is received by its reactions.
It's handy for logging, crash reporting, aborting particular commands or
events, etc.
To:
Middleware is a layer where commands and events can be intercepted before
they reach their listeners. It means you can modify/cancel/extend the
executed command in Command Middleware, or do appropriate operation in
Event Middleware before the published event is received by its reactions.
It's handy for logging, crash reporting, aborting particular commands or
events, etc.
|
||
Naming is hard. I doesn't seem right to have names like `BookListCommand`, | ||
`BookListCommandHandler` and `BookListWhatever` in the project. Here comes the | ||
idea of stories that group related types and make the flow more concrete: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From:
Naming is hard. I doesn't seem right to have names like
BookListCommand
,
BookListCommandHandler
andBookListWhatever
in the project. Here comes the
idea of stories that group related types and make the flow more concrete:
To:
Naming is hard. It doesn't feel right to have names like
BookListCommand
,
BookListCommandHandler
andBookListWhatever
, does it? If you agree, then you can work
around this issue by introducing a new idea into the mix.
You can group all related types into stories, which makes the flow more concrete.
} | ||
``` | ||
|
||
In this sense it's close to user stories used in agile software development |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From:
In this sense it's close to user stories used in agile software development
methodologies.
To:
In this sense, it's close to user stories used in agile software development
methodologies.
assembled piece by piece from different sources, is translated into the | ||
"view state", which is readable by the view to render it on the screen. This | ||
"view state" is kept in memory and valid at a given instant in time until we | ||
switch the context and the current view is deallocated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From:
We believe that in iOS applications in most of the cases there is no real need
for single global state (single source of truth) or multiple sub-states
distributed between stores. Data is stored on disc in local persistence layer,
such as database and cache, or it's fetched from network. Then this content,
assembled piece by piece from different sources, is translated into the
"view state", which is readable by the view to render it on the screen. This
"view state" is kept in memory and valid at a given instant in time until we
switch the context and the current view is deallocated.
To:
We believe that in iOS applications, in most of the cases, there is no real need
for single global state (single source of truth) or multiple sub-states
distributed between stores. Data is stored on disc in local persistence layer,
such as database and cache, or it's fetched from network. Then this content,
assembled piece by piece from different sources, is translated into the
"view state", which is readable by the view to render it on the screen. This
"view state" is kept in memory and valid at a given instant in time until we
switch the context and the current view is deallocated.
@zenangst @RamonGilabert @onmyway133
Now we have 2 demo projects (simple and more advanced) + 1 interactive playground. More about them in README, which is almost completed as well.