DS#is
DS#is(resourceName, instance)
Check to see if an object is an instance of a particular resource. Short for instance instanceof Resource[Resource#class].
You can call
DS#ismultiple ways
DS#is(resourceName, instance)Resource#is(instance)- Where Resource was created byDS#defineResource
| Argument | Type | Description |
|---|---|---|
| resourceName | string | The name of the resource to use. Unnecessary if calling is directly on a Resource. |
| instance | object | The instance to check. |
Examples
var store = new JSData.DS();
var User = store.defineResource('user');
User.class; // "User"
User[User.class]; // function User() {}
var user = User.createInstance({ name: 'John' });
user; // User {name: "John"}
user instanceof User; // false
user instanceof User[User.class]; // true
store.is('user', user); // true
User.is(user); // true
Need help?
Want more examples or have a question? Ask on the Slack channel or post on the mailing list then we'll get your question answered and probably update this wiki.
Updated less than a minute ago
