These are chat archives for canjs/canjs

15th
Dec 2015
Justin Meyer
@justinbmeyer
Dec 15 2015 16:51
We are going to be talking about CanJS and FRP in 10 min: https://plus.google.com/events/cfl4vthuisn5klcip3sqtt87g3c
Guido Smeets
@gsmeets
Dec 15 2015 17:25
Hmm, I see 2.3 introduced new binding syntax, is the 2.2 syntax compatible with 2.3?
Matthew Phillips
@matthewp
Dec 15 2015 17:30
Yes
Guido Smeets
@gsmeets
Dec 15 2015 17:34
Will it be deprecated in 3.0?
Matthew Phillips
@matthewp
Dec 15 2015 17:40
maybe, up for discussion
Probably depends on how hard it is to maintain
Mason Shin
@minsooshin
Dec 15 2015 17:58
does anyone has idea which approach is better for route between define that in init and events?
Guido Smeets
@gsmeets
Dec 15 2015 17:58
Okay. Refactoring that to 2.3 bindings is a good way for me to catch up on writing unit tests for my functional components anyway :) That is, once we finally find two extra developers so I have some breathing room. :/
Mason Shin
@minsooshin
Dec 15 2015 18:00
sorry, never mind
question is wrong
do I need to use route by can.Control? Of I can use events of can.Component?
which is better approach to define route binding?
I am trying to move everything to component, so I used events property of can.Component
but canjs route doc says only about can.Control approach
Justin Meyer
@justinbmeyer
Dec 15 2015 18:23
@minsooshin don't do routing that way
do it state based
have you gone through the DoneJS getting started guide?
it gives a basic example
place my order has an example too
here's an article @joe-crick just wrote: http://blog.bitovi.com/routing-in-canjs/
shows progressive loading w/ donejs
so it's a bit more complex than it has to be
but basically we just check the state
if the state is right, we add the right element
I do it in a slightly different way in bitbals
so I didn't have to write all those if / else's in the template
Mason Shin
@minsooshin
Dec 15 2015 18:41
cool
thanks, I will follow the way
Mason Shin
@minsooshin
Dec 15 2015 20:58
@justinbmeyer this is what I did for routing previously
import 'helpers/urls';
import 'components/layout/';

// list widget components
import 'components/dashboard/';

let loadWidget = (widget) => {
  $('main').html(can.stache('<sc-' + widget + '></sc-' + widget + '>'));
};

can.Component.extend({
  tag: 'trinity',

  init: function(element, options) {
    this.$element = $(element);
    this.options = options;
    can.route('', { widget: '' });
    can.route(':widget');
    can.route(':widget/:sub');
    can.route(':widget/:sub/:id');
    can.route('assets/', false);
    can.route.ready();
  },
  template: can.stache('<sc-trinity-layout></sc-trinity-layout>'),
  events: {
    inserted: () => {
      console.log('DOM has been inserted ======>');
      loadWidget('dashboard');
    },

    route: function(data) {
      console.log(data);
      loadWidget('dashboard');
    },

    ':widget route': function(data) {
      console.log(data);
      loadWidget(data.widget);
    },

    ':widget/:sub route': function(data) {
      console.log(data);
    },

    ':widget/:sub/:id route': function(data) {
      console.log(data);
    }
  }
});
I thought it is also state based component insertion.
Justin Meyer
@justinbmeyer
Dec 15 2015 21:47
it's not as good as using live-binding to drive the change of what elements are being shown
Mason Shin
@minsooshin
Dec 15 2015 22:04
so, I need to import each single component to index.html, right?
can-import
Justin Meyer
@justinbmeyer
Dec 15 2015 23:24
are you building a donejs app @minsooshin ?
if not, no, you will probably already have loaded each component
so no need to use can-import
Mason Shin
@minsooshin
Dec 15 2015 23:56
okay
I am applying the new route approach to canjs app
our applicaiton started with canjs several months ago, so I am curios how it can be transferred to donejs app with minimum code change.
so I am looking forward to have the donejs training next year