Note that there are some explanatory texts on larger screens.

plurals
  1. POremove ko suscrptions in durandal?
    primarykey
    data
    text
    <p>Working with durandal and knockout i have some issues with suscription to the properties. Basically in my viewAttached method i have some suscription to observable properties what work very good at the first time when I load my view. In the second time when I load the view I got some issues due that code inside of suscriptions are executed (thing what i don't want). The code is something like that:</p> <pre><code>export var viewAttached = function (view) { toDate.subscribe(function (newValue) { isLoading(true); return datacontext.getData(newValue).then(function () { isLoading(false); }); }); fromDate.subscribe(function (newValue) { isLoading(true); return datacontext.getData(newValue).then(function () { isLoading(false); }); }); } </code></pre> <p>The code inside of the suscription is executed at the moment to load my view in a second time, what is wrong. I would like know if is possible remove the suscriptions to this properies aftet to unload my view. Is that possible? is possible know when a view is unload ?. any help is apreciated.</p> <p><strong>UPDATE:</strong> I tried remove the suscription in Activate function (see durandal docs) but the suscription code is there yet.</p> <pre><code>export function activate() { //remove suscriptions toDate.subscribe(function (newValue) { //do nothing }); fromDate.subscribe(function (newValue) { //do nothing }); } </code></pre> <p><strong>UPDATE:</strong> The fromDate and ToDate are declared as (i am using typescript)</p> <pre><code>export var fromDate = &lt;any&gt;ko.observable(); export var toDate = &lt;any&gt;ko.observable(); </code></pre> <p>fromDate and toDate and seted by default on activate method:</p> <pre><code>function loadInitData() { var focusDate = ko.observable(selectedDate); fromDate(firstDayOfMonth(focusDate)); toDate(getLastDayOfMonth(focusDate)); loadFilterLookups(); loadRegistrations(); } export function activate() { loadInitData(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload