Skip to content

Comments

Broadcast updates to any globalid-able entity#15

Merged
leastbad merged 11 commits intoleastbad:stream_updatesfrom
julianrubisch:global-id-entity
Sep 20, 2021
Merged

Broadcast updates to any globalid-able entity#15
leastbad merged 11 commits intoleastbad:stream_updatesfrom
julianrubisch:global-id-entity

Conversation

@julianrubisch
Copy link

@julianrubisch julianrubisch commented Sep 16, 2021

Preliminary Steps

  • Equip Compoundable with the ability to wrap any object including GlobalID::Identification
  • Extract ModelBroadcastCallbacks and CollectionBroadcastCallbacks as collaborators
  • Extract CollectionsRegistry and have it handle collection broadcasting

GlobalIDable

Broadcasting to objects including GlobalID::Identification can be done with using ModelBroadcastCallbacks as a kind of semi-private API:

class GlobalIdableEntity
  include GlobalID::Identification
  include CableReady::Broadcastable

  def id
    "fake-id"
  end

  def self.find(id)
    new if id == "fake-id"
  end

  def fake_update
    ModelBroadcasterCallbacks.new(:update).after_commit(self)
  end
end

Gardening 🌱: Refactor "marker" callbacks to lambdas because their naming was confusing

@julianrubisch julianrubisch marked this pull request as ready for review September 19, 2021 09:14
@julianrubisch julianrubisch changed the title WIP: Broadcast updates to any globalid-able entity Broadcast updates to any globalid-able entity Sep 19, 2021
@leastbad
Copy link
Owner

Damn, dude. This PR is elegant.

I am so lucky to have the opportunity to learn from you.

@leastbad leastbad merged commit f3b9d71 into leastbad:stream_updates Sep 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants