Skip to content

Instantly share code, notes, and snippets.

View doasync's full-sized avatar
🙂

Ruslan @doasync doasync

🙂
View GitHub Profile
@doasync
doasync / README.md
Last active March 6, 2019 17:08
createStoreMap & createMapper for working with lists and collections in effector

Usage of createStoreMap

Create $todos store (with an array) using createStore. Then create a $todoList store using createStoreMap.

There will be a map inside of $todoList store. Define map keys with getKey function and values with createValue function. A value object should contain a store inside which will represent an item of your $todos array. Provide this store with a getStore function.

As a result, $todoList will contain a map of value-objects (by keys). Each object will contain an item-store (with an item of a mapped array)

You can filter, map, concat or do anything you want with items of an array inside $todos.

@doasync
doasync / README.md
Last active January 31, 2019 01:12
Why effector?

☄️ Why do you need Effector?

Effector is reactive state manager. It is decentralized, declarative and efficienct.

Effector was created to manage data in complex applications without danger of inflating a monolithic central store. It provides events/effects and reactive storages. It has explicit control flow, Flow and TypeScript type definitions and sufficient API

Here are some principles:

  • application store should be as light as possible - you should not be frightened by the idea that you need to add another store for specific needs
@doasync
doasync / README.md
Created September 22, 2017 12:01
ES6 classes without a class keyword but with class variable

noclass

Here is an example of ES6 classes without a class keyword but with class variables. Looks the same as classes and has the same structure internally.

Example

// class
var Foo = {
  classVariable: true,
@doasync
doasync / pino.js
Last active June 2, 2023 21:57
Pino logger: log prettyfied messages to console + log to separate files WARN, ERROR, FATAL (pino-tee module in child process)
const pino = require('pino');
const childProcess = require('child_process');
const stream = require('stream');
// Environment variables
const cwd = process.cwd();
const {env} = process;
const logPath = `${cwd}/log`;
@doasync
doasync / util.js
Created August 5, 2017 13:25
ES6 utils for arrays and objects
function collapse (arr) {
return [...new Set(arr)];
}
function isIterable(obj) {
return obj != null && typeof obj[Symbol.iterator] === 'function';
}
function collapseAll (...args) {
const all = args.reduce((arr, arg) => {
@doasync
doasync / mongoose.min.js
Created June 20, 2017 14:24
Browserify mongoose js version for browser from 'node_modules' npm package
var gulp = require('gulp');
var gulpSequence = require('gulp-sequence');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var browserify = require('browserify');
var uglify = require('gulp-uglify');
gulp.task('mongoose', function() {
return browserify('./node_modules/mongoose/lib/browser.js')
.bundle()
@doasync
doasync / gulpfile.symlink.js
Last active June 20, 2017 09:41
Relative symbolic links to folders in gulp with vinyl-fs