wire chained factory functions

18 views
Skip to first unread message

julian

unread,
Oct 17, 2013, 12:29:28 PM10/17/13
to cuj...@googlegroups.com
hi,

how would i describe the following relationship in a spec?
there are 2 components, A and B, where A is a function and B is an object.
the relationship between them is that calling component A returns another function A1, which when called returns B.
so, essentially, A is a factory function that produces another factory function A1, which produces instances of B.
hope that makes sense.
thanks in advance!

julian

Brian Cavalier

unread,
Oct 18, 2013, 9:30:15 PM10/18/13
to cuj...@googlegroups.com
Hi Julian,

There's no direct way to trigger nested factories in wire right now.  Aside from refactoring the code to avoid the nested factory, the only thing I can think to do is to introduce a new module whose job it is to traverse the nested factory chain and return B, and use wire's `create` on *that* component.

julian

unread,
Oct 19, 2013, 11:24:28 AM10/19/13
to cuj...@googlegroups.com
ok. thanks for the suggestions. i went the refactoring route.
Reply all
Reply to author
Forward
0 new messages