These are chat archives for meteor-space/general

8th
Sep 2015
Timothy
@timfam
Sep 08 2015 02:57
@DominikGuzei :fire:
Dominik Guzei
@DominikGuzei
Sep 08 2015 08:15
Wow nice, i just realized that the memory-leak problem less serious than i thought. It's because in the Space architecture you almost never depend on transient objects like Mediators or BlazeComponents. So you never have Dependencies: myMediator: 'Mediator' in some other class, that's why those transient objects will never be referenced by mappings and we don't have memory leaks :-D
But still, it is good to have the Space.Injector::release API for special cases, like when you want to swap out long-living sub-systems and free their references.
Dominik Guzei
@DominikGuzei
Sep 08 2015 09:22
Hey @timfam, finally found the motivation to port the TodoMVC example to Javascript:
https://github.com/meteor-space/ui/tree/master/examples
Dominik Guzei
@DominikGuzei
Sep 08 2015 14:34
Hey all, i am excited to announce that we have a simple API to rebuild view-projections from all historic events in the commit-store now: meteor-space/event-sourcing#7
fr0zen
@fr0zen
Sep 08 2015 14:47
hi all! good morning.
Where is the best place to put a redirect after a form submit?
in the component event handling the submit?
Dominik Guzei
@DominikGuzei
Sep 08 2015 14:53
We tend to have something like a RouteController that handles all the logic of redirects etc. based on events
The form should not know about routes / how the whole application works
actually no part of the system should know about routes, except the RouteController
fr0zen
@fr0zen
Sep 08 2015 14:54
Great!
unfortunately it is very simple in the TodoMVC example, so it does not answer your question nicely
fr0zen
@fr0zen
Sep 08 2015 14:55
Yeah. I created more than one route controller. I have a SearchController, I guess it is a good place to put it.
Dominik Guzei
@DominikGuzei
Sep 08 2015 14:55
but just imagine having another handler for something like FormSubmittedevent that redirects
In general we found it to be a good concept to have the various parts of the application only deal with a single responsibility.
Dominik Guzei
@DominikGuzei
Sep 08 2015 15:03
@fr0zen to put it in other words: Things like routing are details that most of your application knows nothing about. The various parts only know how to send/receive events and commands. Components like the RouteController basically translate that from/to the language of your application and shield the rest from these details.
This way it becomes trivial to replace iron-router with flow-router or the next big routing engineTM
fr0zen
@fr0zen
Sep 08 2015 15:32
nice, @DominikGuzei .
one more question
where would be the best place to put helpers used globally?
like the pluralize used in TodoMVC, but to be used in more places.
fr0zen
@fr0zen
Sep 08 2015 15:37
@DominikGuzei not spacebars helpers, just vanilla JS functions
(coffee in my case)
Dominik Guzei
@DominikGuzei
Sep 08 2015 15:39
ok, if the helpers need access to the dependency injection system then you could have something like a ApplicationHelpers singleton that you require where you need it

but of course you can also just use a vanilly object API like

MyHelpers =
  pluralize: (word) ->otherHelper: ->

and reference that in your code

btw. the injection system supports auto-mapping, so you don't have to map MyHelpers in this case but can just require it via:

Dependencies:
  helpers: 'MyHelpers'

if MyHelpers is globally accessible it will just auto-map it for you behind the scenes

then in the code of the class that declared the Dependencies you can just use it like:
class MyComponent extends Space.ui.BlazeComponent
  @register 'my_blaze_template'
  Dependencies:
    helpers: 'MyHelpers'
  myFunc: -> @helpers.pluralize('item')
Dominik Guzei
@DominikGuzei
Sep 08 2015 15:45
or if you don't care about dependency injection just reference it directly:
class MyComponent extends Space.ui.BlazeComponent
  @register 'my_blaze_template'
  myFunc: -> MyHelpers.pluralize 'item'
fr0zen
@fr0zen
Sep 08 2015 15:50
nice @DominikGuzei, exactly what I was looking :)
thanks
Dominik Guzei
@DominikGuzei
Sep 08 2015 15:51
you're welcome ;-)
fr0zen
@fr0zen
Sep 08 2015 15:51
I'll do it via Singleton and DI to keep the pattern
Dominik Guzei
@DominikGuzei
Sep 08 2015 15:52
yeah it's better to go with one or the other style, mixing is just confusing ;-)
Dominik Guzei
@DominikGuzei
Sep 08 2015 21:54
Hey everyone, space:base@2.4.1 brings a better way to configure modules and applications:
https://github.com/meteor-space/base#configuring-modules-and-applications