# Observable remove not found?

**URL:** <https://forums.fusetools.com/t/observable-remove-not-found/3437>\
**Category:** General\
**Created:** [November 9, 2017, 8:25pm UTC](https://forums.fusetools.com/t/observable-remove-not-found/3437 "2017-11-09T20:25:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![R0b0tn1k](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/r0b0tn1k/32/49_2.png) [@R0b0tn1k](https://forums.fusetools.com/u/R0b0tn1k)\
**Post date:** [November 9, 2017, 8:25pm UTC](https://forums.fusetools.com/t/observable-remove-not-found/3437/1 "2017-11-09T20:25:43Z")

</div>

I have an observable which I use to track files that need to be downloaded. Once added to the observable, it’s downloaded. Once download is complete, remove the item from the observable.

All works except one which for some reason fails.

```auto
dlarr.onValueChanged(module, function(item) {
	if (item){
		console.log("changed=" + item)
		var oReq = new XMLHttpRequest();
		oReq.open("GET", item, true);
		oReq.responseType = "arraybuffer";
		oReq.onload = function (oEvent) {
			var arrayBuffer = oReq.response;
			if (arrayBuffer) {
				var fname = item.replace('%2F','/');
        		fname = fname.substring(fname.lastIndexOf('/')+1,fname.lastIndexOf('.')+4);

				var path = FileSystem.dataDirectory + "/" + fname;
				FileSystem.writeBufferToFile(path, arrayBuffer);
			}
			console.log(' I want to remove ' + JSON.stringify(item));
			console.log('Downloaded, removing: ' + item);

			if (dlarr.contains(item)){dlarr.remove(item);}
			
			var kolku = dlarr.length;
			console.log('dlarr.count =' + kolku);
		};
		oReq.send(null);   
	} 					        
});

```

However, I get the following error:

```auto
[Viewport]: I want to remove "https://firebasestorage.googleapis.com/v0/b/dont-be-a-tourist.appspot.com/o/Tour_Assets%2Fnonessential.png?alt=media&token=fa47d074-1460-41be-aa4c-24acca67f9c4"
[Viewport]: Downloaded, removing: https://firebasestorage.googleapis.com/v0/b/dont-be-a-tourist.appspot.com/o/Tour_Assets%2Fnonessential.png?alt=media&token=fa47d074-1460-41be-aa4c-24acca67f9c4
[Viewport]: changed=https://firebasestorage.googleapis.com/v0/b/dont-be-a-tourist.appspot.com/o/Tour_Assets%2Fhistorical.png?alt=media&token=9d4b2413-ff71-401e-b7fc-c775206e00be
[Viewport]: dlarr.count =12
[Viewport]: I want to remove "https://firebasestorage.googleapis.com/v0/b/dont-be-a-tourist.appspot.com/o/Tour_Assets%2Fnonessential.png?alt=media&token=fa47d074-1460-41be-aa4c-24acca67f9c4"
[Viewport]: Downloaded, removing: https://firebasestorage.googleapis.com/v0/b/dont-be-a-tourist.appspot.com/o/Tour_Assets%2Fnonessential.png?alt=media&token=fa47d074-1460-41be-aa4c-24acca67f9c4
[Viewport]: Fuse.Scripting.ScriptException: Name: Error: Observable.remove(): item not found
Error message: Uncaught Error: Observable.remove(): item not found
File name: FuseJS/Observable.js
Line number: 892
Source line: throw new Error("Observable.remove(): item not found");
JS stack trace: Error: Observable.remove(): item not found
    at ValueObservable.Observable.remove (FuseJS/Observable.js:892:9)
    at fuseXMLHttpRequest.oReq.onload (MainView.ux:159:11)
    at fuseXMLHttpRequest.dispatch (js/XMLHttpRequest.js:227:27)
    at self._fuseHttpRequest.ondone (js/XMLHttpRequest.js:146:13)

  at Fuse.Scripting.V8.Context.ThrowPendingExceptions () <0x11e254690 + 0x00054> in <filename unknown>:0 
  at Fuse.Scripting.V8.Function.Call (System.Object[] args) <0x11e257390 + 0x003dd> in <filename unknown>:0 
  at Fuse.Reactive.FuseJS.Http+FuseJSHttpRequest.OnDone (Uno.Net.Http.HttpMessageHandlerRequest res) <0x120819bc0 + 0x0009e> in <filename unknown>:0 
  at Uno.Net.Http.HttpMessageHandlerRequest+DispatchClosure.Run () <0x120819b20 + 0x00066> in <filename unknown>:0 
  at Fuse.Reactive.ThreadWorker.RunInner () <0x11e251440 + 0x004ba> in <filename unknown>:0 
[Viewport]: I want to remove "https://firebasestorage.googleapis.com/v0/b/dont-be-a-tourist.appspot.com/o/Tour_Assets%2Fnonessential.png?alt=media&token=fa47d074-1460-41be-aa4c-24acca67f9c4"
[Viewport]: Downloaded, removing: https://firebasestorage.googleapis.com/v0/b/dont-be-a-tourist.appspot.com/o/Tour_Assets%2Fnonessential.png?alt=media&token=fa47d074-1460-41be-aa4c-24acca67f9c4
[Viewport]: Fuse.Scripting.ScriptException: Name: Error: Observable.remove(): item not found
Error message: Uncaught Error: Observable.remove(): item not found
File name: FuseJS/Observable.js
Line number: 892
Source line: throw new Error("Observable.remove(): item not found");

```

How is this possible? If’s there to initiate a download, but not there to remove it self afterwards?

---

<div class="post-metadata">

**Author:** ![R0b0tn1k](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/r0b0tn1k/32/49_2.png) [@R0b0tn1k](https://forums.fusetools.com/u/R0b0tn1k)\
**Post date:** [November 9, 2017, 8:48pm UTC](https://forums.fusetools.com/t/observable-remove-not-found/3437/2 "2017-11-09T20:48:50Z")

</div>

A bit more digging.

Seems that all items being added to observable are the same. Presuming once that item is deleted, it’s deleting all items, since they are the same?

```auto
mage dont exist, adding to dl: https://previews.123rf.com/images/saiko3p/saiko3p1405/saiko3p140500384/28086072-SKOPJE-MACEDONIA-MAY-30-Kale-Fortress-is-a-historic-fortress-located-in-the-old-town-on-May-30-2013--Stock-Photo.jpg
[Viewport]: changed = https://raw.githubusercontent.com/mediaelement/mediaelement-files/master/echo-hereweare.mp4
[Viewport]: Audio dont exist, adding to dl: small.mp4
[Viewport]: changed = https://raw.githubusercontent.com/mediaelement/mediaelement-files/master/echo-hereweare.mp4
[Viewport]: Image dont exist, adding to dl: http://www.balkaninsight.com/en/file/show//Images/Images.New/Places/Skopje/Mac%20Gov%20Building/Mac%20Gov%20Dec%202014%20%20by%20SJM%20(6).JPG
[Viewport]: changed = https://raw.githubusercontent.com/mediaelement/mediaelement-files/master/echo-hereweare.mp4
[Viewport]: Audio dont exist, adding to dl: big_buck_bunny_240p_30mb.mp4
[Viewport]: changed = https://raw.githubusercontent.com/mediaelement/mediaelement-files/master/echo-hereweare.mp4
[Viewport]: Image dont exist, adding to dl: https://media-cdn.tripadvisor.com/media/photo-s/02/2d/7c/16/macedonia-square.jpg
[Viewport]: changed = https://raw.githubusercontent.com/mediaelement/mediaelement-files/master/echo-hereweare.mp4
[Viewport]: Audio dont exist, adding to dl: big_buck_bunny_240p_20mb.mp4
[Viewport]: changed = https://raw.githubusercontent.com/mediaelement/mediaelement-files/master/echo-hereweare.mp4
[Viewport]: Image dont exist, adding to dl: https://upload.wikimedia.org/wikipedia/commons/thumb/c/c0/Skopje_X48.JPG/269px-Skopje_X48.JPG
[Viewport]: changed = https://raw.githubusercontent.com/mediaelement/mediaelement-files/master/echo-hereweare.mp4
[Viewport]: Image dont exist, adding to dl: skopje.jpg
[Viewport]: changed = https://raw.githubusercontent.com/mediaelement/mediaelement-files/master/echo-hereweare.mp4
[Viewport]: Image dont exist, adding to dl: Skopje-Macedonia-HD-Wallpaper-00397.jpg
[Viewport]: changed = https://raw.githubusercontent.com/mediaelement/mediaelement-files/master/echo-hereweare.mp4
[Viewport]: Image dont exist, adding to dl: Macedonia-Skopje-Fountain-and-Alexander-the-Great-statue-in-Macedonia-Square.jpg
[Viewport]: changed = https://raw.githubusercontent.com/mediaelement/mediaelement-files/master/echo-hereweare.mp4
[Viewport]: Image dont exist, adding to dl: old-bazaar-skopje-590.jpg
[Viewport]: changed = https://raw.githubusercontent.com/mediaelement/mediaelement-files/master/echo-hereweare.mp4
[Viewport]: Image dont exist, adding to dl: skopje.jpg

```

No matter what I add to the observable:

```auto
dlarr.add(el.Photo);
dlarr.add(el.Audio);
dlarr.add(imgUrl);

```

It seems to register only the last file?

```auto
changed = https://raw.githubusercontent.com/mediaelement/mediaelement-files/master/echo-hereweare.mp4
[Viewport]: Audio dont exist, adding to dl: small.mp4

```

---

<div class="post-metadata">

**Author:** ![R0b0tn1k](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/r0b0tn1k/32/49_2.png) [@R0b0tn1k](https://forums.fusetools.com/u/R0b0tn1k)\
**Post date:** [November 9, 2017, 9:38pm UTC](https://forums.fusetools.com/t/observable-remove-not-found/3437/3 "2017-11-09T21:38:08Z")

</div>

Seems to be an issue with the async call initiating the .add to dlArr. I fixed it.
