Forked from Captain Anonymous's Pen WrbaVK.
A Pen by Carlos de la Orden on CodePen.
| export const layout = { | |
| content: [{ | |
| type: 'row', | |
| content:[{ | |
| //this indicates GL that it should ReactDOM.render this component | |
| type:'react-component', | |
| //component registerd name (more later) | |
| component: 'test-component', | |
| //additional props you want for your component | |
| props: { label: 'A' } |
Forked from Captain Anonymous's Pen WrbaVK.
A Pen by Carlos de la Orden on CodePen.
| function foo({movieCount}){ | |
| console.log(movieCount); | |
| //modify provided obj? no way | |
| movieCount = 0; | |
| } | |
| function oldFoo(obj){ | |
| console.log(obj.movieCount); | |
| //modify provided obj? yes it's possible and dangerous |
| /** | |
| * Proxy an Array - add all* property to filter by object predicate, and any* to emulate underscore some/any | |
| * | |
| * For example: proxy an array of objects, having some Boolean values on each of them | |
| * following the is* predicate form. We'll then trap get calls, to return allXXX (sub array) or to | |
| * query anyXXX (Boolean) | |
| * | |
| */ | |
| let Users = new Proxy([ | |
| { id: 1, username: 'Charlie', isAdmin: true, isRobot: false }, |
| //Validation Proxy example | |
| let handler = { | |
| //Intercept any object property set operation | |
| set: function(obj, prop, value){ | |
| if(prop === 'age' && !Number.isInteger(value)){ | |
| throw new TypeError('Age should be an integer number'); | |
| } | |
| obj[prop] = value; | |
| } | |
| } |
| //Default values | |
| let defaultValuesHandler = { | |
| get(target,name) { | |
| return name in target ? target[name] : 'My default value' | |
| } | |
| }; | |
| let target = { | |
| name: 'Carlos', | |
| favGame: 'Mass Effect' |