Skip to content

Instantly share code, notes, and snippets.

View YonathanMeguira's full-sized avatar
🤩
Happy

Yonathan Meguira YonathanMeguira

🤩
Happy
View GitHub Profile
@YonathanMeguira
YonathanMeguira / query.ts
Last active August 21, 2018 08:22
query.ts
import { QueryEntity } from '@datorama/akita';
import { ListStore, ListsState } from './shopika.store';
import { List, Item } from './shopika.model';
export class ListQuery extends QueryEntity<ListsState, List> {
constructor(protected store: ListStore) {
super(store);
}
}
@YonathanMeguira
YonathanMeguira / store.ts
Last active August 19, 2018 06:44
store.ts
import { EntityState, EntityStore, StoreConfig, getInitialActiveState, ActiveState } from '@datorama/akita';
import { List } from './shopika.model';
export interface ListsState extends EntityState<List>, ActiveState { }
@StoreConfig({ name: 'lists' })
export class ListStore extends EntityStore<ListsState, List> {
constructor() {
super();
}
import './polyfills';
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { enableAkitaProdMode, persistState } from '@datorama/akita';
enableAkitaProdMode();
@YonathanMeguira
YonathanMeguira / add.ts
Last active August 21, 2018 08:25
add component
import { List, Item, ShopikaService } from '../state';
export class AddListComponent {
list: List;
constructor(private shopikaService: ShopikaService) { }
saveList() {
this.shopikaService.addList(this.list);
}
@YonathanMeguira
YonathanMeguira / model.ts
Last active August 19, 2018 06:35
model.ts
import { ID } from '@datorama/akita';
export interface List {
id: ID;
name: string;
date: number | Date;
items: Item[];
}
export interface Item {
@YonathanMeguira
YonathanMeguira / EntityState.ts
Last active August 19, 2018 06:42
Entity.ts
export interface EntityState<E> {
entities: HashMap<E>;
ids: ID[];
loading: boolean;
error: any;
}
@YonathanMeguira
YonathanMeguira / QueryEntity.ts
Created August 16, 2018 11:42
Query Entity class
selectAll(options: {
asObject: true;
filterBy?: SelectOptions<E>['filterBy'];
limitTo?: number;
sortBy?: undefined;
sortByOrder?: undefined;
}): Observable<HashMap<E>>;
selectAll(options: {
filterBy: SelectOptions<E>['filterBy'];
limitTo?: number;
@YonathanMeguira
YonathanMeguira / app.js
Created August 31, 2018 06:11
websocket socket.io
const express = require("express");
const socketio = require("socket.io");
const _ = require("lodash");
const actions = require("./actions");
const port = process.env.PORT || 5000;
const env = process.env.NODE_ENV || "development";
const app = express();
@YonathanMeguira
YonathanMeguira / index.js
Created October 2, 2018 09:00 — forked from Kreshnik/index.js
Receive SMS through SMPP with NodeJS
var smpp = require('smpp');
var session = smpp.connect('smpp://SEVER_IP');
var request = require('request');
var connected = false;
session.on('connect', function () {
connected = true;
@YonathanMeguira
YonathanMeguira / init.ts
Last active December 6, 2018 15:10
slider initialization
/**
* @license
* Copyright Datorama. All Rights Reserved.
*
* Use of this source code is governed by an Apache License 2.0 license that can be
* found in the LICENSE file at https://github.com/datorama/client-core/blob/master/LICENSE
*/
import { AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';