These are chat archives for canjs/canjs

Apr 2017
Gira Minus
Apr 10 2017 18:02
Works well :)
Kevin Phillips
Apr 10 2017 18:04
Electron is what we show in the DoneJS 1.0 guides for building DoneJS apps for desktop
glad it’s working for you @gKreator
Viktor Busko
Apr 10 2017 23:45

Hi, maybe someone could give me some advice in my issues.
I'm working on some components that works on canjs, but I have couple of pre-conditions:

  1. Very often I should communicate with JS that isn't canjs so basically I insert some canjs components into some page that contains pure js or jquery.
  2. I'm using canjs 2.2.9 I know that its pretty old, but unfortunately this is something that I can't change.

I have such case:
(you can see sources in devtools or I can share it somehow)
Basically this is some textarea with additional logic that I need to implement. (like twitter/facebook etc.)

And right now I have 2 issues:

  1. Is it possible to listen outside (in outer component or from other components on the page) event that I dispatch here (isLimitExceeded setter):

I need some way to communicate between components, and for example listen for this event in parent component and disable send button depends on data that I provide with event.
The only way that I found is add inserted event in parent component ( and in this component do something like:'super-input')), "mycustomevent", function() {
    // do some logic

But this looks weird so I think maybe there is better approach ?

  1. Its more generic and not related to canjs directly, but since I need to do this in canjs...
    I need to support translations, so the question is what is correct way to do this. I know about example with translation helper in canjs docs. But it's translates some dates etc.
    In my case I need to have an ability to translate random string that may have params like Hello ${username}, because on different languages we can have different word order.
    For example this placeholder in my text area (example above) can contain author name and should be translated as well.
    And seems that stache/mustache helpers can handle this something like:

{{#i18n 'Hello ${key1} and ${key2}' key1 key2}}

...or something like that.

But I'm stucked with getting translated strings from the server. How this should be organized ?
I was thinking about writing client-side store (key - value map) for translations. And than helper that I mentioned above will try to get translation from the server (assume I have endpoint that can return me json with translations). After success it puts data to the store in order to not request the same string next time.

Is it sounds ok ? Maybe someone has such experience.