Skip to content

Commit 54b309c

Browse files
committed
Updated documentation
1 parent e3ce055 commit 54b309c

File tree

5 files changed

+83
-137
lines changed

5 files changed

+83
-137
lines changed

README.md

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,38 @@ implementation which provides the following classes:
1111
It uses [Bootstrap](https://getbootstrap.com/) to implement the underlying user
1212
interface, adding a few components.
1313

14-
## Clone, Build, Release
14+
## Use
1515

16-
You'll need to use `npm` to install as a dependency in your module. Here is what
17-
I do on my Mac which has homebrew installed:
16+
Add the framework as a dependency in your project:
1817

1918
```bash
20-
[bash] brew install npm
21-
[bash] cd $PROJECTS
22-
[bash] git clone git@github.com:djthorpe/js-framework.git
23-
[bash] cd js-framework
24-
[bash] npm install
25-
[bash] npm build
19+
[bash] echo "@djthorpe:registry=https://npm.pkg.github.com" >> .npmrc
20+
[bash] npm install @djthorpe/js-framework
2621
```
2722

28-
This will place the files in the `dist` folder. There is a github action which
29-
runs on a new release to publish the package.
23+
Import assets and create a controller in your JavaScript:
3024

31-
## Use
25+
```javascript
26+
import '@djthorpe/js-framework/dist/assets/fonts/bootstrap-icons.woff';
27+
import '@djthorpe/js-framework/dist/assets/fonts/bootstrap-icons.woff2';
3228

33-
Use the framework as follows:
29+
// Controllers
30+
import { Controller } from '@djthorpe/js-framework';
3431

35-
```bash
36-
[bash] brew install npm
37-
[bash] cd $PROJECTS
38-
[bash] git clone git@github.com:@owner/js-project.git
39-
[bash] cd js-project
40-
[bash] npm init
41-
[bash] echo "@djthorpe:registry=https://npm.pkg.github.com" >> .npmrc
42-
[bash] npm install @djthorpe/js-framework
32+
// Run application
33+
window.addEventListener('DOMContentLoaded', () => {
34+
const jsframework = require('@djthorpe/js-framework');
35+
const app = jsframework.Controller.New(Controller);
36+
app.main();
37+
});
4338
```
4439

45-
## Class Reference
40+
In reality, you would subclass the `Controller` class, and create models, views
41+
and providers within the controller, then use `addEventListener` for each view
42+
and provider to react to events. More informaton is provided in the documentation.
43+
44+
## Reference
45+
46+
The reference is provided in the `dist/doc` folder in the published package, or at
47+
https://djthorpe.github.io/js-framework/
4648

47-
The class reference is included in the `dist` folder of the module, and uses `jsdoc` in order to create from the Javascript source.

config/jsdoc.config.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@
1111
"encoding": "utf8",
1212
"readme": "./README.md",
1313
"destination": "./dist/doc",
14-
"recurse": true,
15-
"template": "./node_modules/clean-jsdoc-theme",
16-
"theme_opts": {
17-
"theme": "light"
18-
}
14+
"recurse": true
1915
},
2016
"plugins": [
2117
"./node_modules/@ckeditor/jsdoc-plugins/lib/export-fixer/export-fixer.js"

js/provider.js

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Error from './error';
44
import Emitter from './emitter';
55

66
// ////////////////////////////////////////////////////////////////////////////
7-
// CONSTANTS
7+
// EVENTS
88

99
const EVENT_ROOT = 'mvc.provider';
1010
const EVENT_STARTED = `${EVENT_ROOT}.started`;
@@ -14,6 +14,59 @@ const EVENT_ADDED = `${EVENT_ROOT}.added`;
1414
const EVENT_CHANGED = `${EVENT_ROOT}.changed`;
1515
const EVENT_DELETED = `${EVENT_ROOT}.deleted`;
1616

17+
/**
18+
* Request start event, which is emitted when a request is initiated.
19+
*
20+
* @event mvc.provider.started
21+
* @property {Provider} sender - The provider that emitted the event.
22+
* @property {string} url - The url of the endpoint.
23+
*/
24+
25+
/**
26+
* Request completed event, which is emitted when a request is successfully completed.
27+
*
28+
* @event mvc.provider.completed
29+
* @property {Provider} sender - The provider that emitted the event.
30+
* @property {boolean} changed - When true, indicates that the request resulted in a change
31+
* to the objects stored in the provider.
32+
*/
33+
34+
/**
35+
* Request error event, which is emitted when a request is not completed successfully.
36+
*
37+
* @event mvc.provider.completed
38+
* @property {Provider} sender - The provider that emitted the event.
39+
* @property {Error} error - Provides the reason for the request not completing
40+
* successfully.
41+
*/
42+
43+
/**
44+
* Object added event, which is emitted when a request adds a new object to the provider.
45+
*
46+
* @event mvc.provider.added
47+
* @property {Provider} sender - The provider that emitted the event.
48+
* @property {Model} object - Provides the reason for the request not completing
49+
* successfully.
50+
*/
51+
52+
/**
53+
* Object changed event, which is emitted when a request replaces an existing object.
54+
*
55+
* @event mvc.provider.changed
56+
* @property {Provider} sender - The provider that emitted the event.
57+
* @property {Model} object - The object which has been added to the provider.
58+
* @property {Model} existing - The object which has been replaced in the provider.
59+
*/
60+
61+
/**
62+
* Object deleted event, which is emitted when a request removes an object from
63+
* the provider.
64+
*
65+
* @event mvc.provider.deleted
66+
* @property {Provider} sender - The provider that emitted the event.
67+
* @property {Model} object - The object which has been deleted from the provider.
68+
*/
69+
1770
// ////////////////////////////////////////////////////////////////////////////
1871
// PROVIDER CLASS
1972

package-lock.json

Lines changed: 3 additions & 106 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@djthorpe/js-framework",
3-
"version": "0.0.19",
3+
"version": "0.0.20",
44
"description": "Javascript Framework",
55
"main": "dist/js/index.js",
66
"scripts": {
@@ -24,7 +24,6 @@
2424
"homepage": "https://github.com/djthorpe/js-framework#readme",
2525
"devDependencies": {
2626
"@ckeditor/jsdoc-plugins": "^24.4.2",
27-
"clean-jsdoc-theme": "^3.2.4",
2827
"css-loader": "^5.2.2",
2928
"eslint": "^7.24.0",
3029
"eslint-config-airbnb-base": "^14.2.1",

0 commit comments

Comments
 (0)