Giter Site home page Giter Site logo

Comments (1)

therabidbanana avatar therabidbanana commented on July 28, 2024

Likely instead of having a hook for rescheduling:

def reschedule_events_on_update
self.class.events.each do |name, data|
attr_changed_method = data[:watch] || data[:at]
if previous_changes[attr_changed_method]
reschedule(name, data)
end
end
end
def reschedule(name, data)
if data[:at]
event = event_data_for_signature(data).merge(
was: previous_changes[data[:at]].try(:first) || send("#{data[:at]}_was")
)
Reactor::Event.reschedule(name, event) if should_fire_reactor_event?(data)
end
end

We would make it so scheduled events could abort by updating the need_to_fire logic to care about scheduling as well as the generic "ifarg" logic:

if data['actor_type']
actor = data["actor_type"].constantize.unscoped.find(data["actor_id"])
publishable_event = actor.class.events[name.to_sym]
ifarg = publishable_event[:if] if publishable_event
end
need_to_fire = case ifarg
when Proc
actor.instance_exec(&ifarg)
when Symbol
actor.send(ifarg)
when NilClass
true
end

In theory, if we queue a job with Reactor data including the attribute we're watching to schedule and current value, then we can check the value is still equal to the most recent value when the actor gets hydrated:

actor = data["actor_type"].constantize.unscoped.find(data["actor_id"])

In publishable, we use the :at param and call that method to get the value - we could save :at_attribute as the actual attribute so we can compute this check on

at: (signature[:at] ? send(signature[:at]) : nil)

from reactor.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.