Skip to content

Instantly share code, notes, and snippets.

@andrekovac
Forked from anonymous/index.html
Last active September 9, 2016 12:06
Show Gist options
  • Save andrekovac/6c6e9026e85b55d04bb61216b34ab2e9 to your computer and use it in GitHub Desktop.
Save andrekovac/6c6e9026e85b55d04bb61216b34ab2e9 to your computer and use it in GitHub Desktop.
JS BinExample to understand React Native ListView and JS bind() better// source http://jsbin.com/tufoso
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Example to understand React Native ListView and JS bind() better">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
/******* Example to understand React Native ListView, bind() and currying *****/
"use strict";
function listView(renderRow) {
// bind some data to renderRow callback
var render = renderRow.bind(null, "REAL DATA FROM ListView", 2);
// call the modified callback
render();
}
var renderRow1 = function renderRow1(myRowDataPlaceHolder, myIdPlaceholder) {
console.log("A component with " + myRowDataPlaceHolder + " data, id: " + myIdPlaceholder);
};
var renderRow2 = function renderRow2(myRowDataPlaceHolder) {
console.log("A component with " + myRowDataPlaceHolder + " data and NO id provided here.");
};
// Call renderStuff with callback function 'renderRow'
listView(renderRow2);
</script>
<script id="jsbin-source-javascript" type="text/javascript">/******* Example to understand React Native ListView, bind() and currying *****/
function listView(renderRow) {
// bind some data to renderRow callback
var render = renderRow.bind(null, "REAL DATA FROM ListView", 2);
// call the modified callback
render();
}
var renderRow1 = function(myRowDataPlaceHolder, myIdPlaceholder) {
console.log("A component with " + myRowDataPlaceHolder +
" data, id: " + myIdPlaceholder);
};
var renderRow2 = function(myRowDataPlaceHolder) {
console.log("A component with " + myRowDataPlaceHolder +
" data and NO id provided here.");
};
// Call renderStuff with callback function 'renderRow'
listView(renderRow2);</script></body>
</html>
/******* Example to understand React Native ListView, bind() and currying *****/
"use strict";
function listView(renderRow) {
// bind some data to renderRow callback
var render = renderRow.bind(null, "REAL DATA FROM ListView", 2);
// call the modified callback
render();
}
var renderRow1 = function renderRow1(myRowDataPlaceHolder, myIdPlaceholder) {
console.log("A component with " + myRowDataPlaceHolder + " data, id: " + myIdPlaceholder);
};
var renderRow2 = function renderRow2(myRowDataPlaceHolder) {
console.log("A component with " + myRowDataPlaceHolder + " data and NO id provided here.");
};
// Call renderStuff with callback function 'renderRow'
listView(renderRow2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment