Git Product home page Git Product logo

Comments (2)

damn avatar damn commented on May 25, 2024

System would be defined like this:

; ns com.stuartsierra.component

(defsystem start
  "Begins operation of this component. Synchronous, does not return
  until the component is started. Returns an updated version of this
  component."
  [component])

(defsystem stop
  "Ceases operation of this component. Synchronous, does not return
  until the component is stopped. Returns an updated version of this
  component."
  [component])

And components like this: (from /test examples)

; ns com.stuartsierra.component-test

(defcomponent :d {:keys [my-c b] :as this}
  (start [_]
    (log 'd.start this)
    (assert (started? b))
    (assert (started? my-c))
    (assoc this ::started? true))
  (stop [_]
    (log 'd.stop this)
    (assert (started? b))
    (assert (started? my-c))
    (assoc this ::started? false)))

(defcomponent :e {:keys [] :as this}
  (start [_]
    (log 'e.start this)
    (assoc this ::started? true))
  (stop [_]
    (log 'e.stop this)
    (assoc this ::started? false)))

(defn system-1 []
  ; deliberately scrambled order
  {:e {}
   :c (component/using {} [:a :b])
   :b (component/using {} [:a])
   :d (component/using {}
                       {:b :b
                        :my-c :c})
   :a {}})

I have omitted giving the components a random :state integer like in the tests to make it more clear that we can just work with plain maps.

from component.

lambdasierra avatar lambdasierra commented on May 25, 2024

Hello, Michael, and thanks for your interest! Congrats on the release of your entity-component system, and I'm glad you found interesting connections to Component. However, I consider com.stuartsierra.component to be in its maintenance phase. It has been stable and largely unchanged for many years, so any changes to the design or public interfaces would be unexpectedly disruptive to the many projects that depend on it.

If you are interested in exploring that design space, I would recommend doing it in a separate project under a different name. There is plenty left to explore, as the many extensions and variations show!

You may also be interested in the addition of :extend-via-metadata to the Lifecycle protocol in Component 0.4.0, which allows plain maps to implement Lifecycle.

Thanks again and have fun exploring!

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.