Project KT

Knowledge Transfer

TOC

  • Dev tricks
  • AppState and routing.
  • CanJS upgrade branch state
  • CanJS 2.3 features and links
  • General recommendations
  • Questions

Dev tricks

  • Use steal-remove-* comments to keep dev code:

 

          //!steal-remove-start

          import ‘models/fixtures’

          console.log(‘Here is my log’)

          //!steal-remove-end

 

See http://stealjs.com/docs/steal-tools.BuildOptions.html removeDevelopmentCode option.

Dev tricks

  • Debug from console:


        $(‘page-inbound-files’).viewModel()


  • Dynamically import a module (even in PROD!):


       System.import(‘utils/commonUtils').then(function(m){

               console.log('imported: ', m);

               // do smth here or attach to window:

               window.commonUtils = m;

       });

       commonUtils.default.isRO();

AppState and routing

   

  • AppState is bound to can.route.
  • We use push-state routing which means navigation to a page affects AppState.
  • All properties except for “page” should have “serialize=false”.

CanJS upgrade branch

 

$ git tag |grep canjs-upgrade
        canjs-upgrade
        canjs-upgrade-m4-unclaimed

 

$ git log --grep "25655208" --oneline canjs-upgrade

 

$ git rev-list --reverse --grep="25655208" canjs-upgrade

 

CanJS 2.3

  • New binding syntax:
    • one/two-way bindings

 

  • Function expression call VS helper expression
    • helper receives computes;
    • function expression passes values as is.

 

http://blog.bitovi.com/canjs-2-3-release/

General recommendations

  • Always reproduce a radar issue in local with fixtures.

 

  • Keep tests in a working condition:
    • regularly run the tests:
      • grunt test
      • http://localhost:8080/test/all_unit_tests.html
      • http://localhost:8080/test/all_tests.html
    • keep tests up-to-date with fixtures.

 

  • Prefer functional programming over state mutation.

Questions?

Thank you!

It was a pleasure working with you! =)

Project KT

By Ilya Fadeev

Project KT

  • 38