11import MasterExamples from './MasterExamples.js' ;
22// used for examples
33import { ProxifyHook } from '../../JavaScript/Classes/Helper/ProxifyHook.js' ;
4- import { Join } from '../../JavaScript/Classes/Traps/Data/Join .js' ;
4+ import { Subscribe } from '../../JavaScript/Classes/Traps/Data/Subscribe .js' ;
55
6- export default class JoinDocs extends MasterExamples {
6+ export default class SubscribeDocs extends MasterExamples {
77 constructor ( makeGlobal ) {
88 super ( makeGlobal ) ;
9- this . name = 'joinDocs ' ;
9+ this . name = 'subscribeDocs ' ;
1010 return this . html ( __ ( 'div' ) , ...this . text ( ) ) ;
1111 }
1212 text ( ) {
1313 return [
14- 'Join ' ,
15- `The trap called Join at /JavaScript/Classes/Traps/Data/Join .js, does make a relationship between values on two
14+ 'Subscribe ' ,
15+ `The trap called Subscribe at /JavaScript/Classes/Traps/Data/Subscribe .js, does make a relationship between values on two
1616 different objects. Source automatically pushes designated values on localKey to target (destination[key]). A Dom
1717 usecase scenario would be to have a state object, which gets manipulated by the result of your api calls,
1818 and directly maps to a DOM nodes content.` ,
19- `$join (destination, key, localKey, func = null);
19+ `$subscribe (destination, key, localKey, func = null);
2020 <ul>
2121 <li>destination: object = the object which holds the target property</li>
2222 <li>key: string = the name of the target property (can be purposefully wrong, incase the default behavior
@@ -25,15 +25,15 @@ export default class JoinDocs extends MasterExamples {
2525 <li>[func]: function = a callback, which receives: the newValue and can handle things on its own manually</li>
2626 </ul>
2727 => returns the Proxy<br><br><br>
28- $disjoin (destination, key, localKey);
28+ $unsubscribe (destination, key, localKey);
2929 <ul>
3030 <li>destination: object = the object which holds the target property</li>
3131 <li>key: string = the name of the target property</li>
3232 <li>localKey: string = the name of the source property</li>
3333 </ul>
3434 => returns the Proxy` ,
3535 `import { ProxifyHook } from './JavaScript/Classes/Helper/ProxifyHook.js;<br>
36- import { Join } from './JavaScript/Classes/Traps/Data/Join .js';<br><br>` ,
36+ import { Subscribe } from './JavaScript/Classes/Traps/Data/Subscribe .js';<br><br>` ,
3737 'Example One' ,
3838 this . example1 ,
3939 `Please, open the console in your developer tools and change the string values of state.a, state.b or state.c!` ,
@@ -44,7 +44,7 @@ export default class JoinDocs extends MasterExamples {
4444 }
4545 example1 ( receiver ) {
4646 // assemble the ProxifyHook with the minimum traps required
47- const inject = new ProxifyHook ( Join ( ) ) . get ( ) ;
47+ const inject = new ProxifyHook ( Subscribe ( ) ) . get ( ) ;
4848
4949 // proxify the object to which binding shall take place
5050 const state = this . makeGlobal ( 'state' , inject (
@@ -60,10 +60,10 @@ export default class JoinDocs extends MasterExamples {
6060 const p2 = inject ( document . createElement ( 'p' ) ) ;
6161 const p3 = inject ( 'p' ) ;
6262
63- // join nodes innerHTML to the values of state 'a', 'b' and 'c'
64- state . $join ( p1 , 'innerHTML' , 'a' ) ;
65- state . $join ( p2 , 'innerHTML' , 'b' ) ;
66- state . $join ( p3 , 'innerHTML' , 'c' ) ;
63+ // subscribe nodes innerHTML to the values of state 'a', 'b' and 'c'
64+ state . $subscribe ( p1 , 'innerHTML' , 'a' ) ;
65+ state . $subscribe ( p2 , 'innerHTML' , 'b' ) ;
66+ state . $subscribe ( p3 , 'innerHTML' , 'c' ) ;
6767
6868 // append all to body, has to use the raw node, since we don't proxify the body in this statement
6969 receiver . appendChild ( p1 ) ;
@@ -72,7 +72,7 @@ export default class JoinDocs extends MasterExamples {
7272 }
7373 example2 ( receiver ) {
7474 // assemble the ProxifyHook with the minimum traps required
75- const inject = new ProxifyHook ( Join ( ) ) . get ( ) ;
75+ const inject = new ProxifyHook ( Subscribe ( ) ) . get ( ) ;
7676
7777 // proxify the object to which binding shall take place
7878 const state = this . makeGlobal ( 'state' , inject (
@@ -84,8 +84,8 @@ export default class JoinDocs extends MasterExamples {
8484 // append ul to body
8585 const ul = receiver . appendChild ( document . createElement ( 'ul' ) ) ;
8686
87- // join ul by custom function to the values of state 'a'
88- state . $join ( ul , undefined , 'a' , ( values ) => {
87+ // subscribe ul by custom function to the values of state 'a'
88+ state . $subscribe ( ul , undefined , 'a' , ( values ) => {
8989 ul . innerHTML = '' ;
9090 values . forEach ( value => {
9191 const li = document . createElement ( 'li' ) ;
@@ -94,7 +94,7 @@ export default class JoinDocs extends MasterExamples {
9494 } ) ;
9595 } ) ;
9696 setTimeout ( ( ) => {
97- // the limitation is, that the prop has to be set directly, in the future Join will may support push, splice, etc. on arrays
97+ // the limitation is, that the prop has to be set directly, in the future Subscribe will may support push, splice, etc. on arrays
9898 state . a = state . a . concat ( [ 'and hi!' ] ) ;
9999 } , 5000 ) ;
100100 }
0 commit comments