Giter Site home page Giter Site logo

Comments (4)

weavejester avatar weavejester commented on May 21, 2024 1

Sorry, I don't understand. In what way are refsets for composite keys not already supported?

from integrant.

RickMoynihan avatar RickMoynihan commented on May 21, 2024

Well I tried and it didn't seem to work, and I don't see it documented anywhere. Though I realise now that my issue is pretty ambiguous. Essentially I'd like an ig/refset to return all instances of the key they compose; without having to derive sub-keys.

e.g. semantically something like:

{[:app/component :instance/one] {}
  [:app/component :instance/two] {}

  :app/components {:components #ig/refset :app/component}
}

from integrant.

weavejester avatar weavejester commented on May 21, 2024

It should work. I just tested it right now:

user=> (require '[integrant.core :as ig])
nil

user=> (defmethod ig/init-key :app/component [_ v] v)
#object[clojure.lang.MultiFn 0x3792163 "clojure.lang.MultiFn@3792163"]

user=> (defmethod ig/init-key :app/components [_ v] v)
#object[clojure.lang.MultiFn 0x3792163 "clojure.lang.MultiFn@3792163"]

user=> (ig/init {[:app/component :instance/one] {:inst 1}
                 [:app/component :instance/two] {:inst 2}
                 :app/components {:components (ig/refset :app/component)}})

{[:app/component :instance/one] {:inst 1}
 [:app/component :instance/two] {:inst 2}
 :app/components                {:components #{{:inst 1} {:inst 2}}}}

from integrant.

RickMoynihan avatar RickMoynihan commented on May 21, 2024

Ahh many thanks, I can confirm this does indeed work.

It looks like when I tried I'd mistyped and used a non-namespaced keyword as the instance key.

from integrant.

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.