Skip to content

Instantly share code, notes, and snippets.

@thenikso
thenikso / observables-with-async-generators.js
Last active August 20, 2019 18:55
This is how you could have the RxJS observables using async generators and for-await-of
function makeSubject() {
const COMPLETE = {};
let send;
let error;
let deferred;
const subject = async function * () {
while(true) {
const data = await deferred;
if (data === COMPLETE) {
return;
// A Mobx friendly utility to ease the late dereference of
// objects' observable properties.
// Using Ramda here but you can use your own version of these functions
import { path, init, last, mapObjIndexed } from 'ramda';
// This is the supporting class, see `late` and `deref` later for actual use
class LateDeref {
constructor(obj, field) {
this.obj = obj;
@thenikso
thenikso / cyclejs-makeComponent.js
Created January 7, 2016 21:38
Cycle.js component maker helper function
import { Observable } from 'rx';
import Cycle from '@cycle/core';
import { makeDOMDriver, hJSX } from '@cycle/dom';
import isolate from '@cycle/isolate';
// A helper method to streamline the creation of CycleJS components
export function makeComponent(...funcs) {
return (isolationName) => isolate(function(sources) {
const sinks = funcs.reduce((steps, f) => {
@thenikso
thenikso / input-type-file.js
Last active August 13, 2020 04:39
AngularJS file input handling directive
(function () {
'use strict';
angular.module('app.Components.InputTypeFile', [])
// When required, this module will automatically handle
// `ng-model` in file inputs.
//
// Usage:
//
@thenikso
thenikso / parallax-box.js
Created April 16, 2015 08:52
AngularJS parallax effect component
'use strict';
(function() {
var $window, parallaxItems, addParallaxItem, removeParallaxItem, updateParallax;
angular.module('app.Components.ParallaxBox', [])
.directive('parallaxBox', function() {
return {
@thenikso
thenikso / noflo.js
Last active December 21, 2015 13:29
NoFlo for browser downloadable at http://noflojs.org/download/ is currently broken. This is an usable version of it usable with the instructions provided in the download page.
;(function(){
/**
* Require the given path.
*
* @param {String} path
* @return {Object} exports
* @api public
*/
function require(path, parent, orig) {