Skip to content

Instantly share code, notes, and snippets.

View splincode's full-sized avatar
💬
печатает...

Максим Иванов splincode

💬
печатает...
View GitHub Profile
import { Component } from '@angular/core';
import { Store, Select } from '@ngxs/store';
import { Observable } from 'rxjs';
import { Dispatch } from '@ngxs-labs/dispatch-decorator'
import { CountState } from './store/counter/count.state';
import { Increment, Decrement } from './store/counter/count.actions';
@Component({
selector: 'my-app',
export class Increment {
public static readonly type = '[Counter] Increment';
}
export class Decrement {
public static readonly type = '[Counter] Decrement';
}
import { State, Action } from '@ngxs/store';
import { Increment, Decrement } from './count.actions';
@State<number>({
name: 'count',
defaults: 0
})
export class CountState {
@Action(Increment) public increment({ setState }) {
setState(state => ++state);
<script src="https://unpkg.com/redux@latest/dist/redux.min.js"></script>
<p>
Counter: <span id="value">0</span>
<button id="increment">+</button>
<button id="decrement">-</button>
</p>
<script>
function counterReducer(state, action) {
/*! highlight.js v9.15.9 | BSD3 License | git.io/hljslicense */
!function(e){var n="object"==typeof window&&window||"object"==typeof self&&self;"undefined"==typeof exports||exports.nodeType?n&&(n.hljs=e({}),"function"==typeof define&&define.amd&&define([],function(){return n.hljs})):e(exports)}(function(a){var f=[],u=Object.keys,N={},c={},n=/^(no-?highlight|plain|text)$/i,s=/\blang(?:uage)?-([\w-]+)\b/i,t=/((^(<[^>]+>|\t|)+|(?:\n)))/gm,r={case_insensitive:"cI",lexemes:"l",contains:"c",keywords:"k",subLanguage:"sL",className:"cN",begin:"b",beginKeywords:"bK",end:"e",endsWithParent:"eW",illegal:"i",excludeBegin:"eB",excludeEnd:"eE",returnBegin:"rB",returnEnd:"rE",relevance:"r",variants:"v",IDENT_RE:"IR",UNDERSCORE_IDENT_RE:"UIR",NUMBER_RE:"NR",C_NUMBER_RE:"CNR",BINARY_NUMBER_RE:"BNR",RE_STARTERS_RE:"RSR",BACKSLASH_ESCAPE:"BE",APOS_STRING_MODE:"ASM",QUOTE_STRING_MODE:"QSM",PHRASAL_WORDS_MODE:"PWM",C_LINE_COMMENT_MODE:"CLCM",C_BLOCK_COMMENT_MODE:"CBCM",HASH_COMMENT_MODE:"HCM",NUMBER_MODE:"NM",C_NUMBER_MODE:"CNM",
data = data.mergeDeep({
items: {
[NEW_ITEM_ID]: { id: NEW_ITEM_ID, name: 'ITEM-NEW', value: 0 }
},
keys: [ ...INITIAL_DATA.keys, NEW_ITEM_ID],
count: (data.get('count') as number) + 1
});
function checkLanguage(greeter, closing){
if (closing) {
const newGreeter = clone(greeter);
newGreeter.greeting = 'Goodbye';
return newGreeter;
}
return greeter;
}
const foo = { greeting: 'Hello' };
function checkLanguage(greeter, closing){
if (closing) {
greeter.greeting = 'Goodbye';
}
}
const foo = { greeting: 'Hello' };
checkLanguage(foo, true);
console.log(foo.greeting + ' world!');
// XML Documentation:
// tslint:disable-next-line:max-line-length
// https://docs.microsoft.com/en-us/previous-versions/office/developer/office-xp/aa140066(v=office.10)#odc_xmlss_ss:column