Skip to content

Instantly share code, notes, and snippets.

View CrisDan1905's full-sized avatar

Cristian Danilo Gutiérrez CrisDan1905

View GitHub Profile
@CrisDan1905
CrisDan1905 / config-overrides.js
Created April 17, 2018 04:01
Example for implementing web workers with react
module.exports = function override(config, env) {
config.module.rules.push({
test: /\.worker\.js$/,
use: { loader: 'worker-loader' }
})
return config;
}
@CrisDan1905
CrisDan1905 / test.worker.js
Created April 17, 2018 03:58
Example for implementing web workers with react
self.addEventListener("message", startCounter);
function startCounter(event) {
console.log(event.data, self)
let initial = event.data;
setInterval(() => this.postMessage(initial++), 1000);
}
@CrisDan1905
CrisDan1905 / App.js
Created April 17, 2018 03:53
Example for implementing web workers with react
...
...
import myWorker from './test.worker';
class App extends Component {
constructor() {
super();
this.state = {counter: 0};
}
@CrisDan1905
CrisDan1905 / package.json
Last active April 17, 2018 04:03
example of web workers with react
......
......
"scripts": {
......
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test --env=jsdom",
"eject": "react-scripts eject"
......
@CrisDan1905
CrisDan1905 / app.component.ts
Last active December 1, 2017 03:33
implement of global library in an Angular app
// app.component.ts
ngOnInit() {
const $h1 = $('h1');
$h1.css('color', 'blue');
}
@CrisDan1905
CrisDan1905 / .angular-cli.json
Last active December 1, 2017 03:26
Short demonstration of how implement global JS libraries in an Angular app
/** .angular-cli.json */
"scripts": [
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/select2/dist/js/select2.min.js"
]