Permalink
Browse files

Added "on demand" view test for new joCache

  • Loading branch information...
1 parent 2d3ef8e commit c8d35be17af6f486211c5aa22310abca5beb9aae @davebalmer davebalmer committed Jun 14, 2010
Showing with 28 additions and 1 deletion.
  1. +28 −1 samples/test.js
View
@@ -135,7 +135,8 @@ var App = (function() {
list = new joMenu([
{ title: "Login", id: "login" },
{ title: "Checklist", id: "checklist" },
- { title: "Help", id: "help" }
+ { title: "Help", id: "help" },
+ { title: "On Demand View", id: "test" }
])
]);
menu.activate = function() {
@@ -147,6 +148,32 @@ var App = (function() {
if (id == "login") {
stack.push(login);
}
+ else if (id == "test") {
+ stack.push(joCache.get("test"));
+ }
+ }, this);
+
+ // we can defer creating views until they're needed
+ // using joCache
+ joCache.set("test", function() {
+ var back;
+
+ joLog("creating test view on demand");
+
+ var card = new joCard([
+ new joTitle("Home"),
+ new joGroup([
+ new joCaption("This view was created on-demand using joCache.get('test'). From now on, this view will not be recreated, but pulled from the cache.")
+ ]),
+ new joDivider(),
+ back = new joButton("Back")
+ ]);
+
+ back.selectEvent.subscribe(function() {
+ stack.pop();
+ });
+
+ return card;
}, this);
moreback.selectEvent.subscribe(function() { stack.pop(); }, this);

0 comments on commit c8d35be

Please sign in to comment.