Giter VIP home page Giter VIP logo

Comments (2)

SevereOverfl0w avatar SevereOverfl0w commented on August 18, 2024 1

This seems reasonable. It might even make sense to double check there's not a common ancestor protocol.

from bidi.

usernolan avatar usernolan commented on August 18, 2024

That is a great idea. I looked a bit further into this, and found that extending these protocols to clojure.lang.AFn using the existing clojure.lang.Fn implementations works as expected for MultiFn:

(extend-protocol bidi/Matched
  clojure.lang.AFn
  (resolve-handler [this m] (bidi/succeed this m))
  (unresolve-handler [this m] (when (= this (:handler m)) "")))

(extend-protocol bidi.ring/Ring
  clojure.lang.AFn
  (request [f req _] (f req)))

This approach would obviously extend to regular fns as well. As a consumer (naive outsider perspective, apply as many grains of salt as appropriate 😂), it seems intuitive to treat MultiFn identically to Fn in this case, given the implementations. Doing so would require almost no effort—I'd be happy to submit a PR if the team is open to it.

Otherwise, I don't mind including the extension in each instance of relevant bidi-consuming code. In any case, I really appreciate the extensibility of the design—it has made the library super easy to work with. Thank you! 🙏

from bidi.

Related Issues (20)

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.