Git Product home page Git Product logo

Comments (4)

 avatar commented on May 25, 2024

Hi! Thanks for your interest in Component.

I have experimented with sub-systems or partially-started systems in the past (that was the original idea behind the component-keys argument to start-system) and found that it doesn't work well in practice. You get confusing behavior if different components are "started" at different times. This is a limitation of the design of the Component library, and I have never found a satisfactory solution.

Instead, since Systems are basically just maps, I recommend creating partial systems: You can assoc, dissoc and merge systems of components to create a system that contains just the components you want, then start that.

Best wishes for your componentizing!

from component.

holyjak avatar holyjak commented on May 25, 2024

Hi, thank you! I understand.

Thereal issue is getting the correct subset of the system map, including all transitive dependencies. It would be helpful if Component had a helper function for that...

from component.

 avatar commented on May 25, 2024

getting the correct subset of the system map, including all transitive dependencies.

You can! All the pieces are there. It would look something like this:

(require '[com.stuartsierra.component :as component]
         '[com.stuartsierra.dependency :as dep])

(defn subsystem [system subsystem-keys]
  (let [graph (component/dependency-graph system (keys system))
        selected (into (set subsystem-keys)
                       (mapcat #(dep/transitive-dependencies graph %))
                       subsystem-keys)]
    (merge (component/system-map)
           (select-keys system selected))))

Note: this is completely untested! 😀

from component.

holyjak avatar holyjak commented on May 25, 2024

Nice, thank you! I did not know about dep/transitive-dependencies

from component.

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.