04.07.2019 Views

frontend-developer-1

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Customize and Create JavaScript<br />

<br />

<br />

HELPFUL LINKS:<br />

• https://magento.stackexchange.com/a/89821/13<br />

Demonstrate an understanding of the different types of knockout<br />

observables.<br />

Observables allow a cascading effect of functionality to happen when data changes.<br />

Typically, when we build interfaces, we receive an input’s change event and then<br />

process the data. While that works, observables remove us having to write the code<br />

to link the data change to the events that transpire. As such, they are very powerful.<br />

The basic observable is created with a call to this.price =<br />

ko.observable(12.42). To get an observables value, it needs to be called as a<br />

function without arguments. (e.g. this.price()).<br />

To update the value, it needs to be called as a function with an argument (e.g.<br />

this.price(12.99).<br />

Any update to the value triggers any dom elements that knockout rendered with<br />

that observable to be re-rendered.<br />

Copyright © 2018, SwiftOtter, Inc.<br />

95

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!