Browse Source

Update README.

Herbert Vojčík 1 year ago
parent
commit
e59cd1fa63
1 changed files with 11 additions and 10 deletions
  1. 11 10
      README.md

+ 11 - 10
README.md

@@ -17,9 +17,9 @@ How
 ===
 
 Brikz aims to be minimal, so just copy it and include it where appropriate (it is just one `Brikz` constructor). Then instantiate it:
-```js
-var api = /* skeleton of my object */;
-var brikz = new Brikz(api);
+```
+  var api = /* skeleton of my object */;
+  var brikz = new Brikz(api);
 ```
 
 Then, you should have some parts:
@@ -30,27 +30,28 @@ function Foo(brikz, api) {
 }
 
 function Bar(brikz, api) {
-  brikz.ensure("foo");
   this.internalBar = function () { ... };
   api.publishedBar = function () {
     ...;
     // use brikz.foo and brikz.foo.internalFoo as you see fit
     // it now contains the object, not the factory
-    // of course, you can use api.externalFoo as well
+    // You can _not_ use api.publishedFoo directly in Bar,
+    // but you can use it in any code to be run later.
     ...;
   };
 }
+Bar.deps = ["foo"];
 ```
 
-The `ensure` function synchronously tries to include part named `foo` before continuing. Thus, if you have circular dependencies, you end up with stack overflow. Don't have them. :wink:
+The `deps` array synchronously tries to process part named `foo` before processing bar. Thus, if you have circular dependencies, you end up with stack overflow. Don't have them. :wink:
 
 You then put the parts in `brikz` object, rebuild it and you have `api` ready for use:
 ```
-brikz.foo = Foo;
-brikz.bar = Bar;
-brikz.rebuild();
+  brikz.foo = Foo;
+  brikz.bar = Bar;
+  brikz.rebuild();
 
-api.publishedBar(...);
+  api.publishedBar(...);
 ```
 
 You can add / delete / change parts later and call `rebuild` again. Parts that are not functions, are left as is (their internal as well as API part); parts that are functions are instantiated again and merged in. Parts that are `null`ed are removed.