Skip to content

Instantly share code, notes, and snippets.

Christian Alfoni christianalfoni

Block or report user

Report or block christianalfoni

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ObservableState.dart
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:rxdart/rxdart.dart' as rx;
Observer currentObserver;
class Observer {
Map<rx.Observable, StreamSubscription> _subscriptions = Map();
rx.BehaviorSubject _subject = rx.BehaviorSubject();
View eventhub.dart
class Store {
Store([Store parent = null]) {
this.emit = parent == null ? (dynamic action) {
if (_subscribers.containsKey(action)) {
_subscribers[action].forEach((cb) => cb());
}
} : parent.emit;
}
Map<Action, Set<Function>> _subscribers = new Map();
Function subscribe(List<Action> actions, Function callback) {
@christianalfoni
christianalfoni / case.md
Last active Apr 3, 2019
The case for action based change detection
View case.md

The case for action based change detection

There are several approaches to detecting change, for example:

  1. Mobx, Vue js, Overmind JS: Mutation detection using getters/setters or proxies.

  2. Redux: Reference comparison, typically combined with immutability (Is previous value different than current?)

  3. Cerebral JS: Path matching. With single state trees you can match what paths components depend on with what paths are being mutated in the state tree

View release.md

Updated packages

package from version to version
overmind 17.0.0 17.1.0
overmind-angular 17.0.0 17.1.0
overmind-devtools 18.0.0 18.1.0
overmind-react 18.0.0 18.1.0
overmind-vue 17.0.0 17.1.0
View action.ts
export const open: Action = async ({ state, actions, effects }) => {
state.currentPage = Page.ADMIN
const messageUpdates = await effects.api.getAdminMessageUpdates()
state.admin.messageUpdates = messageUpdates
state.admin.users = await effects.api.getUsers(
messageUpdates.map((update) => update.userUid)
)
if (state.admin.messageUpdates.length) {
state.admin.isLoadingFeed = true
View data.json
This file has been truncated, but you can view the full file.
export default JSON.parse(`{
"0": {
"actionId": 3,
"actionName": "routeProcessView",
"executionId": 1,
"name": "setRoute",
"operatorId": 0,
"path": [],
"type": "action",
View types.ts
// Based on this comment: https://github.com/Microsoft/TypeScript/issues/20965#issuecomment-370114910
declare module "bem-jsx" {
export type BlockType<Props extends { [prop: string]: string }> = React.ComponentType<Props> & {
[key: string]: React.ComponentType<any>;
};
export default function block<T extends string, Props = { [K in T]?: string }>(
blockName: string,
modifiers?: T[],
@christianalfoni
christianalfoni / proposal.md
Last active Feb 13, 2019
Dan Abramov article proposal
View proposal.md

The APIs React.PureComponent and React.memo are used to optimize performance of React. From the documentation:

If your React component’s render() function renders the same result given the same props and state, you can use React.PureComponent for a performance boost in some cases.

Questions I hope would inspire to write another technical article on React, focusing on these APIs and performance:

  1. I thought React always renders based on its props and state. What other reasons would make comparison break the behaviour of a component?
@christianalfoni
christianalfoni / release.md
Created Feb 11, 2019
release_with_commit_hashes
View release.md

Updated packages

package from version to version
betsy 1.0.2 1.0.2-1549908365086
overmind 15.1.2 16.0.0-1549908365086
overmind-angular 15.1.2 16.0.0-1549908365086
overmind-devtools 16.1.3 17.0.0-1549908365086
overmind-react 16.1.3 17.0.0-1549908365086
overmind-themes 1.0.2 1.0.2-1549908365086
@christianalfoni
christianalfoni / release.md
Last active Feb 11, 2019
Overmind next release
View release.md

Updated packages

package from version to version
betsy 1.0.2 1.0.2
overmind 15.1.2 16.0.0
overmind-angular 15.1.2 16.0.0
overmind-devtools 16.1.3 17.0.0
overmind-react 16.1.3 17.0.0
overmind-themes 1.0.2 1.0.2
You can’t perform that action at this time.