This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Behavior delegation examples | |
OLOO (Objects Linking to Other Objects) pattern idea from Kyle Sypson | |
Example at: Delegating Widget Objects | |
https://github.com/getify/You-Dont-Know-JS/blob/master/this%20%26%20object%20prototypes/ch6.md | |
*/ | |
// good example | |
var base = { | |
a : 3, | |
init: function(b, c) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (window) { | |
// example of OLOO pattern applied to object se serialization and deserialization | |
var dataApi = '{"id":0,"top":10,"left":20,"width":100,"height":150}'; | |
var state = JSON.parse(dataApi); | |
var base = { | |
init: function (data) { | |
var _data = data; // private | |
// defined on object itself not on its protoype | |
Object.defineProperty(this, 'id', { | |
get: function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
<meta charset="utf-8" /> | |
<script> | |
(function () { | |
/* | |
Values remap utility. | |
Use case: Assigning custom values to a range slider. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const compose = (f, ...fs) => x => | |
f === undefined ? x : compose(...fs)(f(x)) | |
const add = x => y => x + y | |
const mult = x => y => x * y | |
const main = compose(add(3), mult(4), add(5), mult(6)) | |
console.log(main(2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Stack Overflow Dojo snippet to be included with copy/paste in answers. | |
*/ | |
<!-- begin snippet: js hide: false console: true babel: false --> | |
<!-- language: lang-js --> | |
require([ | |
'dojo/domReady!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import './App.css'; | |
import { TableData } from '@actyx/industrial-ui' | |
function App() { | |
type Item = Readonly<{ | |
id: string; | |
description: string; | |
value: string; | |
}>; |