|
| 1 | +# Remixer API |
| 2 | +The Remixer class is a singleton class that keeps track of all the Variables and deals with saving/syncing its values. |
| 3 | + |
| 4 | +The following methods are the most commonly used to enable Remixer in your app. |
| 5 | + |
| 6 | +- [remixer.start()](#start-static) |
| 7 | +- [remixer.stop()](#stop-static) |
| 8 | +- [remixer.addBooleanVariable()](#addbooleanvariable-static) |
| 9 | +- [remixer.addColorVariable()](#addcolorvariable-static) |
| 10 | +- [remixer.addNumberVariable()](#addnumbervariable-static) |
| 11 | +- [remixer.addRangeVariable()](#addrangevariable-static) |
| 12 | +- [remixer.addStringVariable()](#addstringvariable-static) |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +### start <sub><sup>`STATIC`</sup></sub> |
| 17 | + |
| 18 | +Appends the HTML iFrame to body of client app. Attaches key listener to toggle Overlay visibility. |
| 19 | + |
| 20 | +#### Syntax |
| 21 | + |
| 22 | +```javascript |
| 23 | +remixer.start(); |
| 24 | +remixer.start(remoteConfig); |
| 25 | +``` |
| 26 | + |
| 27 | +#### Parameters |
| 28 | + |
| 29 | +- **remoteConfig:** *object* |
| 30 | + |
| 31 | + The optional firebase configuration. Provide this configuration if you wish to use the remote controller. |
| 32 | + |
| 33 | + ```javascript |
| 34 | + var remoteConfig = { |
| 35 | + apiKey: "<API_KEY>", |
| 36 | + authDomain: "<PROJECT_ID>.firebaseapp.com", |
| 37 | + databaseURL: "https://<DATABASE_NAME>.firebaseio.com" |
| 38 | + ... |
| 39 | + }; |
| 40 | + ``` |
| 41 | + |
| 42 | +#### Returns void |
| 43 | + |
| 44 | +--- |
| 45 | + |
| 46 | +### stop <sub><sup>`STATIC`</sup></sub> |
| 47 | + |
| 48 | +Removes iFrame and attached key listener. |
| 49 | + |
| 50 | +#### Syntax |
| 51 | + |
| 52 | +```javascript |
| 53 | +remixer.stop(); |
| 54 | +``` |
| 55 | + |
| 56 | +#### Returns void |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +### addBooleanVariable <sub><sup>`STATIC`</sup></sub> |
| 61 | + |
| 62 | +Adds a boolean Variable to array of Variables with optional callback. |
| 63 | + |
| 64 | +#### Syntax |
| 65 | + |
| 66 | +```javascript |
| 67 | +remixer.addBooleanVariable(key, defaultValue); |
| 68 | +remixer.addBooleanVariable(key, defaultValue, callback(variable) { ... } ); |
| 69 | +``` |
| 70 | + |
| 71 | +#### Parameters |
| 72 | + |
| 73 | +- **key:** *string* |
| 74 | + |
| 75 | + The key of the Variable. |
| 76 | + |
| 77 | +- **defaultValue:** *boolean* |
| 78 | + |
| 79 | + The initial default value of the variable. |
| 80 | + |
| 81 | +- `OPTIONAL` **callback:** *function* |
| 82 | + |
| 83 | + The callback method to be invoked when the Variable is updated. The function is passed with the updated variable argument. |
| 84 | + |
| 85 | +#### Returns [BooleanVariable](https://material-foundation.github.io/material-remixer-js/docs/classes/_core_variables_booleanvariable_.booleanvariable.html) |
| 86 | + |
| 87 | +--- |
| 88 | + |
| 89 | +### addColorVariable <sub><sup>`STATIC`</sup></sub> |
| 90 | + |
| 91 | +Adds a color variable to array of variables with optional callback. |
| 92 | + |
| 93 | +#### Syntax |
| 94 | + |
| 95 | +```javascript |
| 96 | +remixer.addColorVariable(key, defaultValue); |
| 97 | +remixer.addColorVariable(key, defaultValue, limitedToValues); |
| 98 | +remixer.addColorVariable(key, defaultValue, limitedToValues, callback(variable) { ... } ); |
| 99 | +``` |
| 100 | + |
| 101 | +#### Parameters |
| 102 | + |
| 103 | +- **key:** *string* |
| 104 | + |
| 105 | + The key of the Variable. |
| 106 | + |
| 107 | +- **defaultValue:** *string* |
| 108 | + |
| 109 | + The initial default value of the variable. |
| 110 | + |
| 111 | +- `OPTIONAL` **limitedToValues:** *string[]* |
| 112 | + |
| 113 | + The optional array of allowed values. |
| 114 | + |
| 115 | +- `OPTIONAL` **callback:** *function* |
| 116 | + |
| 117 | + The callback method to be invoked when the Variable is updated. The function is passed with the updated variable argument. |
| 118 | + |
| 119 | +#### Returns [ColorVariable](https://material-foundation.github.io/material-remixer-js/docs/classes/_core_variables_colorvariable_.colorvariable.html) |
| 120 | + |
| 121 | +--- |
| 122 | + |
| 123 | +### addNumberVariable <sub><sup>`STATIC`</sup></sub> |
| 124 | + |
| 125 | +Adds a number variable to array of variables with optional callback. |
| 126 | + |
| 127 | +#### Syntax |
| 128 | + |
| 129 | +```javascript |
| 130 | +remixer.addNumberVariable(key, defaultValue); |
| 131 | +remixer.addNumberVariable(key, defaultValue, limitedToValues); |
| 132 | +remixer.addNumberVariable(key, defaultValue, limitedToValues, callback(variable) { ... } ); |
| 133 | +``` |
| 134 | + |
| 135 | +#### Parameters |
| 136 | + |
| 137 | +- **key:** *string* |
| 138 | + |
| 139 | + The key of the Variable. |
| 140 | + |
| 141 | +- **defaultValue:** *number* |
| 142 | + |
| 143 | + The initial default value of the variable. |
| 144 | + |
| 145 | +- `OPTIONAL` **limitedToValues:** *number[]* |
| 146 | + |
| 147 | + The optional array of allowed values. |
| 148 | + |
| 149 | +- `OPTIONAL` **callback:** *function* |
| 150 | + |
| 151 | + The callback method to be invoked when the Variable is updated. The function is passed with the updated variable argument. |
| 152 | + |
| 153 | +#### Returns [NumberVariable](https://material-foundation.github.io/material-remixer-js/docs/classes/_core_variables_numbervariable_.numbervariable.html) |
| 154 | + |
| 155 | +--- |
| 156 | + |
| 157 | +### addRangeVariable <sub><sup>`STATIC`</sup></sub> |
| 158 | + |
| 159 | +Adds a range Variable to array of Variables with optional callback. |
| 160 | + |
| 161 | +#### Syntax |
| 162 | + |
| 163 | +```javascript |
| 164 | +remixer.addRangeVariable(key, defaultValue, minValue, maxValue, increment); |
| 165 | +remixer.addRangeVariable(key, defaultValue, minValue, maxValue, increment, callback(variable) { ... } ); |
| 166 | +``` |
| 167 | + |
| 168 | +#### Parameters |
| 169 | + |
| 170 | +- **key:** *string* |
| 171 | + |
| 172 | + The key of the Variable. |
| 173 | + |
| 174 | +- **defaultValue:** *number* |
| 175 | + |
| 176 | + The initial default value of the variable. |
| 177 | + |
| 178 | +- **minValue:** *number* |
| 179 | + |
| 180 | + The allowed minimum value of the variable. |
| 181 | + |
| 182 | +- **maxValue:** *number* |
| 183 | + |
| 184 | + The allowed maximum value of the variable. |
| 185 | + |
| 186 | +- **increment:** *number* |
| 187 | + |
| 188 | + The amount to increment the value. |
| 189 | + |
| 190 | +- `OPTIONAL` **callback:** *function* |
| 191 | + |
| 192 | + The callback method to be invoked when the Variable is updated. The function is passed with the updated variable argument. |
| 193 | + |
| 194 | +#### Returns [RangeVariable](https://material-foundation.github.io/material-remixer-js/docs/classes/_core_variables_rangevariable_.rangevariable.html) |
| 195 | + |
| 196 | +--- |
| 197 | + |
| 198 | +### addStringVariable <sub><sup>`STATIC`</sup></sub> |
| 199 | + |
| 200 | +Adds a string variable to array of variables with optional callback. |
| 201 | + |
| 202 | +#### Syntax |
| 203 | + |
| 204 | +```javascript |
| 205 | +remixer.addStringVariable(key, defaultValue); |
| 206 | +remixer.addStringVariable(key, defaultValue, limitedToValues); |
| 207 | +remixer.addStringVariable(key, defaultValue, limitedToValues, callback(variable) { ... } ); |
| 208 | +``` |
| 209 | + |
| 210 | +#### Parameters |
| 211 | + |
| 212 | +- **key:** *string* |
| 213 | + |
| 214 | + The key of the Variable. |
| 215 | + |
| 216 | +- **defaultValue:** *string* |
| 217 | + |
| 218 | + The initial default value of the variable. |
| 219 | + |
| 220 | +- `OPTIONAL` **limitedToValues:** *string[]* |
| 221 | + |
| 222 | + The optional array of allowed values. |
| 223 | + |
| 224 | +- `OPTIONAL` **callback:** *function* |
| 225 | + |
| 226 | + The callback method to be invoked when the Variable is updated. The function is passed with the updated variable argument. |
| 227 | + |
| 228 | +#### Returns [StringVariable](https://material-foundation.github.io/material-remixer-js/docs/classes/_core_variables_stringvariable_.stringvariable.html) |
0 commit comments