KnockOut JS – Part 1


  • KnockOut.js and MVVM: http://knockoutjs.com/
    • KnockOut.js file used for client side binding and used for client MVVM pattern designs.
    • Knockout:
      • Features
        • Rich client-side interactivity
        • MVVM like pattern
        • Wide browser Support
    • Key Concepts
      • Dependency tracking via observables
        • Var myviewModel = { firstName: ko.observable("John") };
      • Declarative bindings
        • <input data-bind="Value: firstName" />
      • Templating Support
        • Ko.applyBindings(myviewModel);
    • Observables(ko.observable())
      • Both sides(UI and Object) are updated while change the value
    • ComputedObservables
      • Used to calculate a value based on the input
      • Read/write computed
    • observableArray
      • functions : destroy, destroyAll, indexOf, pop, push, remove, removeAll, reverse, shift, slice, sort, splice, unshift
    • Subscribing to changes
      • Register to be notified when changes occur
      • Similar to setter property in .Net
      • Useful when you need to take action when a property changes
        Eg: viewModel.SelectedMake.subscribe(function(){
        viewModel.SelectedModel(undefined);
        }, viewModel);  
    • MVVM:
      • Model –View –View Model
      • Foremost, a separation pattern
      • Not technology specific
      • Works well with data binding

Comments

Popular posts from this blog

SignalR (Push Services with Hubs)–Part 1

Adapter pattern:[Structural]

Singleton Pattern:[Creational]