Skip to content

Instantly share code, notes, and snippets.

@jonataa
Last active March 13, 2019 22:50
Show Gist options
  • Save jonataa/ddaec3f6d5b440a29db84a22de418016 to your computer and use it in GitHub Desktop.
Save jonataa/ddaec3f6d5b440a29db84a22de418016 to your computer and use it in GitHub Desktop.
articles: [
{id: 1, created_at: "..."},
{id: 2, created_at: "..."}
],
articles_events: [
{id: 1, article_id: 1, type: "created", data: {title: "hello", category_id: 3}, created_at: "..."},
{id: 2, article_id: 1, type: "title_updated", data: {title: "hello, world"}, created_at: "..."},
{id: 3, article_id: 1, type: "published", data: {}, created_at: "..."},
{id: 4, article_id: 2, type: "created", data: {title: "foo bar", category_id: 1}, created_at: "..."},
{id: 5, article_id: 2, type: "category_updated", data: {category: 2}, created_at: "..."},
{id: 6, article_id: 2, type: "published", data: {}, created_at: "..."},
{id: 7, article_id: 2, type: "title_updated", data: {title: "fizz buzz"}, created_at: "..."},
{id: 8, article_id: 2, type: "published", data: {}, created_at: "..."},
{id: 9, article_id: 1, type: "drafted", data: {}, created_at: "..."},
]
~> state after event id #1:
articles_draft: [
{id: "...", article_id: 1, title: "hello", category_id: 3},
],
articles_published: []
~> state after event id #2:
articles_draft: [
{id: "...", article_id: 1, title: "hello, world", category_id: 3},
],
articles_published: []
~> state after event id #3:
articles_draft: [],
articles_published: [
{id: "...", article_id: 1, title: "hello, world", category_id: 3}
]
~> state after event id #4:
articles_draft: [
{id: "...", article_id: 2, title: "foo bar", category_id: 1}
],
articles_published: [
{id: "...", article_id: 1, title: "hello, world", category_id: 3}
]
~> state after event id #5:
articles_draft: [
{id: "...", article_id: 2, title: "foo bar", category_id: 2}
],
articles_published: [
{id: "...", article_id: 1, title: "hello, world", category_id: 3}
]
~> state after event id #6:
articles_draft: [],
articles_published: [
{id: "...", article_id: 1, title: "hello, world", category_id: 3},
{id: "...", article_id: 2, title: "foo bar", category_id: 2}
]
~> state after event id #7:
articles_draft: [
{id: "...", article_id: 2, title: "fizz buzz", category_id: 2}
],
articles_published: [
{id: "...", article_id: 1, title: "hello, world", category_id: 3},
{id: "...", article_id: 2, title: "foo bar", category_id: 2}
]
~> state after event id #8:
articles_draft: [],
articles_published: [
{id: "...", article_id: 1, title: "hello, world", category_id: 3},
{id: "...", article_id: 2, title: "fizz buzz", category_id: 2}
]
~> state after event id #9:
articles_draft: [
{id: "...", article_id: 1, title: "hello, world", category_id: 3},
],
articles_published: [
{id: "...", article_id: 2, title: "fizz buzz", category_id: 2}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment