phoenixframework / phoenix_pubsub

Distributed PubSub and Presence platform for the Phoenix Framework
http://www.phoenixframework.org/
MIT License
653 stars 124 forks source link

Suggestion to optimize Tracker.update not to send unnecessary diffs #189

Open satoren opened 2 months ago

satoren commented 2 months ago

Currently, when Tracker.update is run, a new ref is created regardless of whether there is a change or not and a diff is generated.

e.g.

      iex> Phoenix.Tracker.update(MyTracker, self(), "lobby", u.id, fn meta -> Map.put(meta, :away, true) end)
      # Since the same values are set, there is no change in meta, but a diff is reported.
      iex> Phoenix.Tracker.update(MyTracker, self(), "lobby", u.id, fn meta -> Map.put(meta, :away, true) end)

What about making a change or adding an option to suppress this? If this suggestion is acceptable, I will create a patch.