-
Notifications
You must be signed in to change notification settings - Fork 16
/
backbone-react-component.react.txt
51 lines (37 loc) · 3.53 KB
/
backbone-react-component.react.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
BACKBONE-REACT-COMPONENT
VERSION ==> #1.0.0
#Update React component state on Backbone MODEL|COLL changes, and define few helpers.
BACKBONEREACT #React component mixin
BACKBONEREACT.on(RCOMP, OBJ) #Same as using mixin but:
# - must manually do when mounting then do BACKBONEREACT.off(RCOMP) on unmounting
# - do not use props but OBJ.models|collections[.VAR] MODEL|COLL
# (must not define if RCOMP.overrideModel|Collection() defined)
BACKBONEREACT.onModel|Collection
(RCOMP, VAL) #Same as BACKBONEREACT.on(RCOMP, { models|collections VAL })
/=+===============================+=\
/ : : \
)==: MODEL COLLECTION :==(
\ :_______________________________: /
\=+===============================+=/
RCOMP.state.model|collection|VAR #MODEL.attributes[_ARR] based on:
# - RCOMP.props.model|collection[.VAR] MODEL|COLL
# - or (if defined) RCOMP.overrideModel|Collection()->MODEL|COLL
#Updated:
# - when prop changed, i.e. on componentWillReceiveProps, with !== reference comparison
# - on MODEL change, COLL change|update|reset|sort
RCOMP.getModel|Collection() #Current|parent MODEL|COLL
/=+===============================+=\
/ : : \
)==: HELPERS :==(
\ :_______________________________: /
\=+===============================+=/
AJAX LISTENERS ==> #The following members listen to request|sync|error|invalid MODEL|COLL events
#(unless Backbone OBJ.silent true)
RCOMP.isRequesting #BOOL: ongoing AJAX request
RCOMP.hasError #BOOL: if last request failed
RCOMP.error #ERROR: if last request failed
RCOMP.isInvalid #BOOL: reset at each request
RCOMP.$
RCOMP.el|$el #Like Backbone