day8 / re-frame

A ClojureScript framework for building user interfaces, leveraging React
http://day8.github.io/re-frame/
MIT License
5.4k stars 715 forks source link

throw error in unwrap interceptor instead of warning #763

Closed hipitihop closed 1 year ago

hipitihop commented 1 year ago

Motivation: When an event handler is registered using the unwrap standard interceptor, the interceptor expects the event to be dispatched as a two element vector where the second argument is a map. It currently checks for this and issues a console warning when this is not the case. However, this is a somewhat silent failure and the registered handler is still called with the original wrapped event vector. Depending on the handler's fn parameter definitions, this can cause destructuring error, or flow further downstream before an error in the dispatch is detected. In app which mixes both standard and unwrapped handlers (perhaps due to legacy code or third-party libs which don't yet support the unwrap contract, we want to detect an issue as soon as possible.

Change: This PR modifies the unwrap handler to instead throw and error so that a disparity in the contract between the dispatcher and handler is identified as early as possible.