This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Slice } from "@reduxjs/toolkit"; | |
| import { studentSlice } from "./studentSlice"; | |
| type childSelector<P,C> = (state:P) => C; | |
| export const forwardReducer = <P,C>(childSlice:Slice<C>,childSelector:childSelector<P,C>) => { | |
| const reducerDC = {} as any;//will fix types later | |
| for (const key in childSlice.actions) { | |
| if (childSlice.actions.hasOwnProperty(key)) { | |
| const action = childSlice.actions[key]; | |
| reducerDC[action.type] = (state:P, action:any) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function deepMerge(target, source){ | |
| const result = {...target,...source}; | |
| const keys = Object.keys(result); | |
| for(const key of keys){ | |
| const tprop = target[key]; | |
| const sprop = source[key]; | |
| //if two objects are in conflict | |
| if(typeof(tprop) == 'object' && typeof(sprop) == 'object'){ | |
| result[key] = deepMerge(tprop, sprop); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const tapWhenUnsubscribed = <T>(source$: Observable<T>) => ( | |
| fn: (x: T) => void | |
| ) => | |
| new Observable<T>(observer => { | |
| let closedFromSource = false; | |
| const subscription = source$.subscribe( | |
| x => { | |
| observer.next(x); | |
| }, | |
| e => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| namespace connected | |
| { | |
| class Program | |
| { | |
| static (int groupNum, char value) nullGroupVal = (-1, '*'); |