Skip to content

Commit

Permalink
Optimised observer
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinlano authored May 2, 2024
1 parent 93668c3 commit bf13ce0
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions libraries/observer.km3
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package app {


class Subject {



attribute subjectState : OclAny;


reference views[*] : View oppositeOf subject;


query getState() : OclAny
pre: true
post: result = subjectState;

operation addView(v : View ) : void
pre: true
post: views->includes(v);

operation removeView(v : View ) : void
pre: true
post: views->excludes(v);

}




class View {


attribute viewState : OclAny;

reference subject : Subject oppositeOf views;


operation refresh() : void
pre: true
post: viewState = subject.getState();

}





}


0 comments on commit bf13ce0

Please sign in to comment.