Skip to content

Commit

Permalink
Documentation (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBuchholz committed Oct 18, 2017
1 parent fc94b52 commit 3281593
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions doc/tutorials/REQUIRE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
The library offers a way to organize your project by creating separate source files (a.k.a. modules) with dependencies.
The {@see gpf.require.define} API is the main entry point.
The library offers a way to organize the project by creating separate resources files and link them
using dependencies. The {@see gpf.require.define} API is the main entry point.

A resource is referenced using its path. A resource may reference other resources using a relative path.
For the initial call, a base path might be defined using {@see gpf.require.configure}.
The resolved resource name correspond to the concatenation of the base path and the resource path.

Several type of resources files can be linked, type detection is based on the extension (case insensitive):
- **.json** JSON static resource file
- **.js** JavaScript module

Once a resource file is loaded, its associated output is cached using the resolved file name.
Consequently (considering the cache is never cleared):
- If the same resource is accessed twice (using relative path but with the same resolved file name),
the file will be loaded only once
- Any modification applied to the output will be reflected globally

## JSON static resource file

A JSON file is loaded, parsed and the result object is associated to the resource name.


## JavaScript Module

resources => module or static resources

Expand All @@ -11,13 +32,6 @@ Whatever the chosen module format, the very first call must be {@see gpf.require
The factory function is optional and a promised is returned to know whe nthe dependant modules are loaded.
Once the initial call is made, the API supports several formats.

Once loaded, any modification applied to the module is saved. Unless the cache is cleared.

## JSON file

JSON files are loaded, parsed and the result object is associated to the resource.

## GPF Module

In general, the `gpf` symbol is always available. It allows you to access the global context through the
`{@see gpf.context}` API.
Expand Down

0 comments on commit 3281593

Please sign in to comment.