Fork me on GitHub

Hi all I'm a beginner and I have a question I could use some help with. When we use the component model, in the start function of the component, why do we always need to assoc something? Everywhere I've seen online it seems to be required. On my app it seems that it will not run properly unless I assoc a value. Is it possible to be done without assoc anything there?


There is no requirement to assoc anything in the start function


You can see the default start function here which is used for anything that doesn't have a more specific extension of Lifecycle


The default start function does nothing


Start can also return a completing different object as well


You don’t necessarily need to assoc something but the return value ends up as part of the “system”. If your component acquires a handle to communicate with some external system and you’d like to be able to clean that up when you stop the component, you need to include it in the return value.

Jim Strieter16:10:33

(rest some-vector) takes O(1) time right?


I'm pretty sure that you can implement a type that works with rest that would result in rest being any runtime complexity.


but, if some-vector is a clojure vector, then since it's a persistent data structure, it should be able to get it's first level children nodes pretty fast. persistent data structures don't do full collection copying when modified.

pppaul17:10:19 turns out just being a persistent data structure isn't enough to know how it's built. clojure uses "Persistent hash array mapped trie" which is referenced in this article

🙌 1
Alex Miller (Clojure team)21:10:38

in short, the answer is yes

Alex Miller (Clojure team)21:10:00

in long, the answer depends on the data structure. lists or seqs will be O(1) but data structures like vectors, maps, and sets need to produce a seq view and step into it which is often O log base 32 (which is effectively constant)

Jim Strieter11:10:20

some-vec is a built in Clojure vector, so it sounds like yes. Thanks everybody!