Opened 7 years ago

Closed 7 years ago

#16362 closed defect (fixed)

dijit/tree/ObjectStoreModel.fetchItemByIdentity() Fails with dojo/store/MemoryStore

Reported by: Fergus Hadley Owned by: bill
Priority: undecided Milestone: 1.9
Component: Dijit Version: 1.8.1
Keywords: Cc:
Blocked By: Blocking:

Description

The following line in the fetchItemByIdentity() method of dijit/tree/ObjectStoreModel fails when using a MemoryStore? to power the tree:

this.store.get(keywordArgs.identity).then(

because MemoryStores? return a Javascript object not a deferred. It looks like this function is designed to work with the old dojo.data stores...

Error message: "TypeError?: this.store.get(keywordArgs.identity).then is not a function".

The method could also do with some comments about usage. Nothing shows up in the API.

Change History (4)

comment:1 Changed 7 years ago by bill

Component: GeneralDijit
Milestone: tbd1.9
Owner: set to bill
Status: newassigned

Hmm, it should be a when() (dojo/when) rather than a then(), but the fact that Tree is still working with MemoryStore says that fetchItemByIdentity() isn't used at all. Or were you seeing some actual error with Tree? If so, please attach a test case, since our tests aren't catching it.

comment:2 Changed 7 years ago by Fergus Hadley

Thanks for looking at this. I realise, on reflection, that this method is specifically for old-style stores. I was calling it directly and should have been using get(id) instead.

Still, I agree dojo/when would be better and perhaps some documentation... :)

comment:3 in reply to:  2 Changed 7 years ago by bill

Replying to voidstate:

Thanks for looking at this. I realise, on reflection, that this method is specifically for old-style stores.

The issue is that fetchItemByIdentity() isn't used at all, and should be removed. It's got nothing in particular to do with old or new stores.

Still, I agree dojo/when would be better and perhaps some documentation... :)

Well, fetchItemByIdentity() and all the other methods are documented fully in model.js:

fetchItemByIdentity: function(keywordArgs){
	// summary:
	//		Given the identity of an item, this method returns the item that has
	//		that identity through the onItem callback.  Conforming implementations
	//		should return null if there is no item with the given identity.
	//		Implementations of fetchItemByIdentity() may sometimes return an item
	//		from a local cache and may sometimes fetch an item from a remote server.
	// tags:
	//		extension
},

The issue is that ObjectStoreModel doesn't actual extend dojo/tree/model, since it doesn't need to. So, I need to add some doc-comments so the doc parser thinks ObjectStoreModel extends dojo/tree/model.

comment:4 Changed 7 years ago by bill

Resolution: fixed
Status: assignedclosed

In [29980]:

Remove unused fetchItemByIdentity() method from model interface. Left method in deprecated ForestStoreModel and TreeStoreModel classes in case someone (not Tree) is using it, but removed method from ObjectStoreModel since it was never working anyway.

Fixes #16362 !strict

Note: See TracTickets for help on using tickets.