``` vbox { add(SubViewA::class) add(SubViewB::...
# tornadofx
v
Copy code
vbox {
  add(SubViewA::class)
  add(SubViewB::class)
  add(SubViewC::class)
  add(SubViewD::class)
}
Assuming
SubViewX
is a
Fragment
👍 1
a
Super! Thanks!
v
That TornadoFX is made for (short code) 😃
a
I realized it could also be written as vbox { add<SubViewA>() add<SubViewB>() add<SubViewC>() add<SubViewD>() } Is there any differences? Is the one better/more correct than the other, or is it more personal style?
v
E.g.
find<MyFragment>()
can be used to pass parameters to the fragment like
find<MyFragment>(mapOf(MyFragment::myPropert1 to value1, MyFragment::myProperty2 to value2))
😀 1
In the case without parameters, I think, it's a matter of taste
a
Nice! Thanks!
e
The new and preferred syntax is add<SubViewA>() 🙂
a
Thanks! Is there a way to add scope to this? Let's say I'm adding the same fragment multiple times, but want different scopes for the fragments? Or am I doing it wrong then?
e
Yes, the new syntax accepts scopes as parameter, so you can do
add<SubViewA>(Scope())
to create a new scope on the fly.
Oh, and yes that's a very reasonable way of doing it.
v
Interesting... Is it faster? Or just 'cause of opportunity of adding parameters?
e
It was added because it's a nicer syntax. We could have added parameters to the old syntax as well, but the old syntax should be removed in 2.0, so no need 🙂
v
Got it