This file contains 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 { TodoActions } from './todo.actions'; | |
import { Task } from './interfaces/task.interface'; | |
import produce from 'immer'; | |
export const initialState: Array<Task> = []; | |
export const producer = (draft, action) => TodoActions.match(action, { | |
NewTask: task => { | |
draft.push(task); | |
}, |
This file contains 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 { unionize, ofType } from 'unionize'; | |
import { Task } from './interfaces/task.interface'; | |
export const TodoActions = unionize({ | |
NewTask: ofType<Task>(), | |
ToggleTask: ofType<{ id: string }>(), | |
ClearCompleted: {} | |
}, { tag: 'type', value: 'payload' }); |
This file contains 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 { Action } from '@ngrx/store'; | |
import { ActionTypes } from './counter.actions'; | |
export const initialState = 0; | |
export function counterReducer(state = initialState, action: Action) { | |
switch (action.type) { | |
case ActionTypes.Increment: | |
return state + 1; |
This file contains 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 { Action } from '@ngrx/store'; | |
export enum ActionTypes { | |
Increment = '[Counter Component] Increment', | |
Decrement = '[Counter Component] Decrement', | |
Reset = '[Counter Component] Reset', | |
} | |
export class Increment implements Action { | |
readonly type = ActionTypes.Increment; |
This file contains 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 { Actions } from './counter.actions'; | |
import produce from 'immer'; | |
export const initialState = 0; | |
const producer = (draft, action) => Actions.match(action, { | |
Increment: () => draft + 1, | |
Decrement: () => draft - 1, | |
Reset: () => initialState, | |
default: () => {} |
This file contains 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 { unionize } from 'unionize'; | |
export const Actions = unionize({ | |
Increment: {}, | |
Decrement: {}, | |
Reset: {}, | |
}, { tag: 'type' }); |
This file contains 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
// This is added globally by the zip.js library | |
declare const zip: any; | |
@Injectable() | |
export class ZipService { | |
constructor() { | |
zip.workerScriptsPath = 'scripts/'; | |
} |
This file contains 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
export interface ZipEntry { | |
version: number; | |
bitFlag: number; | |
compressionMethod: number; | |
lastModDateRaw: number; | |
lastModDate: string; | |
crc32: number; | |
compressedSize: number; | |
uncompressedSize: number; | |
filenameLength: number; |
This file contains 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
service firebase.storage { | |
match /b/{bucket}/o { | |
match /{userId}/{document=**} { | |
allow read: if request.auth.uid == userId; | |
allow write: if request.auth.uid == userId | |
&& request.auth.token.path == request.resource.name | |
&& request.auth.token.remaining >= request.resource.size; | |
} | |
} | |
} |
This file contains 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
// Three observables | |
const getQuota$ = this.functions.httpsCallable('getQuotaToken')({ id }); | |
const signIn$ = token => this.userService.signInWithToken(token); | |
const doUpload$ = this.doFileUpload(userId, id, file); | |
// Combine | |
getQuota$.pipe( | |
concatMap(({ token }) => signIn$(token)), | |
concatMap(() => doUpload$) | |
); |