I need to execute some code both on initialize and render methods, but as I understand, I canot just modfy them directly when using Chaplin – when I define my own initialize method, my routes stop working.
I also tried afterInitialize() but it seems its not meant to be overrided: https://github.com/chaplinjs/chaplin/issues/168#issuecomment-8015915
You can modify them directly as long you appropriately delegate to the extended prototype.
As you haven’t tagged your question
javascriptorcoffeescript, the following are two solutions for each one. First up is javascript. Notice how we must explicitly invoke the extended function.Next is
coffeescript, which makes this kind of thing significantly easier.