Skip to content

Instantly share code, notes, and snippets.

View nomanHasan's full-sized avatar

Noman Hasan nomanHasan

View GitHub Profile
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
//Import Semantic UI and Font-awesome
import 'semantic-ui-css/semantic.min.css';
import 'font-awesome/css/font-awesome.css'
@nomanHasan
nomanHasan / app.js
Last active December 19, 2017 15:37
CORS configuration
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "http://localhost:4200");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
next();
});
var files = [{name: "a", size: 120}, {name: "b", size: 220}, {name: "c", size: 320}, {name: "d", size: 420}, {name: "e", size: 520}]
var files = files.reduce((sum, f) => {f.start = sum ; console.log(sum, f); return sum+f.size}, 0)
@nomanHasan
nomanHasan / app.component.html
Created October 11, 2017 10:05
#todoapp-angular-ngrx
<app-todo-list></app-todo-list>
@nomanHasan
nomanHasan / app.module.ts
Last active October 12, 2017 09:01
#todoapp-angular-ngrx
import { TodoListComponent } from './components/todo/todo-list/todo-list.component';
import { EffectsModule } from '@ngrx/effects';
import { TodoListItemComponent } from './components/todo/todo-list-item/todo-list-item.component';
import * as TodoReducer from './store/todo/todo.reducer'
// ........................
imports: [
@nomanHasan
nomanHasan / todo.state.ts
Last active April 7, 2018 06:07
#todoapp-angular-ngrx
import Todo from '../../models/todo.model';
export interface TodoState extends Todo{
loading:boolean;
editable: boolean;
edited: boolean;
editing:boolean;
selected: boolean;
@nomanHasan
nomanHasan / todo.reducer.ts
Created October 11, 2017 10:03
9 #todoapp-angular-ngrx
// ........................
function modifyTodoState(state, todo: TodoState, modifications): TodoListState {
return {
...state,
todos: state.todos.map(t => {
if (t._id == todo._id) {
@nomanHasan
nomanHasan / todo.reducer.ts
Created October 11, 2017 10:03
8 #todoapp-angular-ngrx
// ........................
export function TodoReducer(state = defaultState, action: Action) {
switch (action.type) {
//...............
case TodoActions.COMPLETE_TODO: {
@nomanHasan
nomanHasan / todo.reducer.ts
Created October 11, 2017 10:02
7 #todoapp-angular-ngrx
// ........................
export function TodoReducer(state = defaultState, action: Action) {
switch (action.type) {
//...............
case TodoActions.UPDATE_TODO: {
@nomanHasan
nomanHasan / todo.reducer.ts
Created October 11, 2017 10:01
6 #todoapp-angular-ngrx
// ........................
export function TodoReducer(state = defaultState, action: Action) {
switch (action.type) {
//...............
case TodoActions.DELETE_TODO: {