You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The provider is used to fetch JSON objects and arrays from a remote REST source, and stores them. To construct a provider with a model class called MyModelClass,
49
-
50
-
```javascript
51
-
importProviderfrom'@djthorpe/js-framework';
52
-
importMyModelClassfrom'./models';
53
-
54
-
constorigin='https://awesome-data-service.com/';
55
-
constprovider=newProvider(MyModelClass,origin);
56
-
```
57
-
58
-
If the __Model__ class is not provided then a plain vanilla object
59
-
is used. The origin is also optional.
60
-
61
-
You can create a request to a remote API using the `request` method, which will
62
-
return immediately, whilst firing events,
63
-
64
-
```javascript
65
-
constpath='/api/datasource';
66
-
constreq= { method:'GET' };
67
-
constuserInfo=null;
68
-
constinterval=30*1000; // Request every 30 seconds
69
-
provider.request(path,req,userInfo,interval);
70
-
```
71
-
72
-
The `req`, `userInfo` and `interval` arguments are optional. If you use
73
-
an interval, a request is immediately made and then again periodically. To
74
-
cancel an interval, call `provider.cancel();`.
75
-
76
-
The events fired are as followed:
77
-
78
-
`mvc.provider.added` (sender,object)
79
-
`mvc.provider.changed` (sender,object,existing)
80
-
`mvc.provider.deleted` (sender,object)
81
-
`mvc.provider.completed` (sender,changed)
82
-
`mvc.provider.error` (sender,Error)
47
+
The class reference is included in the `dist` folder of the module, and uses `jsdoc` in order to create from the Javascript source.
0 commit comments