Skip to content

Instantly share code, notes, and snippets.

View vivainio's full-sized avatar

Ville Vainio vivainio

View GitHub Profile
angular.module('app').directive('props', function() {
return {
link: function(scope, element, attrs) {
scope.$watchCollection(attrs.props, function(newValues) {
for (const key in newValues) {
if (newValues.hasOwnProperty(key)) {
element[0][key] = newValues[key];
}
}
});
// don't like patching your components with custom hacks? use this!
class MobWrap {
unsubs: (() => void)[] = [];
constructor() {}
autorun(view: (r: IReactionPublic) => any, scope?: any) {
this.unsubs.push(realAutorun(view));
// "fluent" api for chaining stuff
return this;
}
import { autorun } from "mobx";
export function startObserving(component: any, expression: () => void) {
const disposer = autorun(expression);
if (!component.__mobx_unsubs) {
component.__mobx_unsubs = [disposer];
} else {
component.__mobx_unsubs.push(disposer);
}
}

How to clean up a branch

  1. Current branch is features/unclean
  2. git checkout dev
  3. git checkout -b features/cleaned-up
  4. git merge --squash features/unclean
  5. Go to Git Extensions / git gui, and edit the staging (unstage whitespace differences and accidental changes etc)
  6. git push
modifyComplex() {
this.complex = this.complex.concat("newline");
const el = document.querySelector("#mycomplex") as any;
el.strings = this.complex;
}
<div>
<h2>Home</h2>
<p>{{home.message}}</p>
<h3>Without anything</h3>
<my-name></my-name>
<h3>With simple string</h3>
<my-name simplestring="simple static from angular"></my-name>
<h3>With dynamic string</h3>
import { Component, Prop, EventEmitter, Event } from "@stencil/core";
@Component({
tag: 'my-name',
styleUrl: 'my-name.scss'
})
export class MyName {
@Prop() simplestring: string;

Keybase proof

I hereby claim:

  • I am vivainio on github.
  • I am vivainio (https://keybase.io/vivainio) on keybase.
  • I have a public key ASCg5nrmnlPRoj7M6rFdBuk4huR8d-Jxyuf4aJZWAiKw6go

To claim this, I am signing this object:

// linked data (HateOAS) with types
interface HData<T> {
rel: string;
href: string;
data?: T;
}
interface HAction<T, U> {
rel: string;