Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Edited description.

  • Loading branch information...
commit 1c85b6a20d45a9d502699397688d40b46a7edfe9 1 parent 3650a21
authored

Showing 1 changed file with 8 additions and 90 deletions. Show diff stats Hide diff stats

  1. +8 90 README
98 README
@@ -2,98 +2,16 @@ DevShop Js
2 2
3 3 DevShop Js is a pocket-sized minimalist framework of common design patterns for crazy wild spontaneous JavaScript combustion.
4 4
5   -JavaScript Observer Plus+
  5 +Patterns:
6 6
7   -Observer Pattern plus messaging framework with dynamic mapping of events to observer methods.
  7 +Observer/Observable Plus!
  8 +-Observer Pattern plus messaging framework with dynamic mapping of events to observer methods.
8 9
9   -Features
  10 +Model View Controller
  11 +-Classic MVC Pattern
10 12
11   -+Observable keeps collection of dependents (observers).
12   -+Observable is always available to Observer scope.
13   -+'initialize' method for observable start up.
14   -+Observers are notified of state changes via notifyObservers().
15   -+onRegister method for triggering observer start up.
16   -+Dynamic mapping of events to observer methods.
17   -+Event name is tied to the method name for easy wiring of handlers.
  13 +Singleton Factory
  14 +-Supports 'extend', 'instance', and 'implement' for interface methods.
18 15
19   -Example
  16 +Please see 'examples' directory for usage.
20 17
21   -var Echo=new DevShop.Observer({
22   - onKeyUp:function(){
23   - document.getElementById('echo').innerHTML=this.observable.getMsg();
24   - }
25   -});
26   -var Mirror=new DevShop.Observer({
27   - onKeyUp:function(){
28   - var arr=this.observable.getMsg().split('');
29   - var msg='';
30   - if(arr.length>0)
31   - for(var x=arr.length-1;x>=0;x--)
32   - msg+=arr[x];
33   - document.getElementById('mirror').innerHTML=msg;
34   - }
35   -});
36   -var UI=new DevShop.Observable({
37   - initialize:function(){
38   - this.addObserver(Echo);
39   - this.addObserver(Mirror);
40   - },
41   - onKeyUp:function(){
42   - this.notifyObservers('onKeyUp');
43   - },
44   - getMsg:function(){
45   - return document.getElementById('box').value;
46   - }
47   -});
48   -
49   -<body>
50   -<form>
51   - <input onkeyup="UI.onKeyUp()" type="text" id="box" name="box" value=""/>
52   - <div id="echo"></div>
53   - <div id="mirror"></div>
54   -</form>
55   -</body>
56   -
57   -Event/Handler Mapping
58   -
59   -The event name is wired to observer's handler methods. This enables
60   -the use of constants to facilitate notifications and dynamic mapping.
61   -
62   -Example:
63   -
64   -var CarEvents={
65   - START : "onStart",
66   - STOP : "onStop"
67   -};
68   -var Car=new DevShop.Observable({
69   - model:"honda",
70   - onStart:function(){
71   - this.notifyObservers(CarEvents.START);
72   - },
73   - onStop:function(){
74   - this.notifyObservers(CarEvents.STOP);
75   - }
76   -});
77   -
78   -Observerable Initialize Method
79   -
80   -It is also possible to specify observers during "initialize" method.
81   -
82   -Example:
83   -var GPS=new DevShop.Observer({
84   - onStart:function(){
85   - console.log('tracking trip!');
86   - }
87   -});
88   -var Car=new DevShop.Observable({
89   - initialize:function(){
90   - this.addObserver(GPS);
91   - },
92   - model:"honda",
93   - onStart:function(){
94   - this.notifyObservers(CarEvents.START);
95   - },
96   - onStop:function(){
97   - this.notifyObservers(CarEvents.STOP);
98   - }
99   -});

0 comments on commit 1c85b6a

Please sign in to comment.
Something went wrong with that request. Please try again.