Skip to content

Instantly share code, notes, and snippets.

@ezequieltejada
ezequieltejada / FormGroupConfig
Last active December 8, 2020 08:37
FormGroup Config type for subform implementation.
export type FormGroupConfig<T> = {
[P in keyof T]: [
T[P] | { value: T[P]; disabled: boolean },
(AbstractControlOptions | ValidatorFn | ValidatorFn[])?
];
};
@ezequieltejada
ezequieltejada / handleAsyncInputs.ts
Last active November 15, 2022 16:28
How to handle multiple asynchronous inputs
asyncInputsData$ = new BehaviorSubject(null);
/*****
* (13/11/2022) OLD... just use @Inputs
*****/
ngOnChanges(changes: SimpleChanges): void {
const obj = {};
Object.keys(changes).forEach(key => {
obj[key] = changes[key].currentValue;
@ezequieltejada
ezequieltejada / Source.txt
Last active October 12, 2022 11:28
Simple Store Strategy for Angular
https://dev.to/angular/simple-yet-powerful-state-management-in-angular-with-rxjs-4f8g
@ezequieltejada
ezequieltejada / explanation.md
Last active March 31, 2022 16:50
Optional properties

Explanation

To avoid errors that a property is undefined when creating or updating a document in firestore, we can use a snipet like this one to have is property added to the object ONLY when the flag is true.

In this example the flag is defined outside optionalContent due to clarity purposes, however we can replace it with !!usesPrinter directly.

const flag = !!usesPrinter

const optionalContent = {
 ...(flag &amp;&amp; {PRINTER_PERMISSION: usesPrinter}),
@ezequieltejada
ezequieltejada / aeProjectStructure.md
Last active June 22, 2024 13:53
Angular Architecture... so far.

App Engine Architecture (so far...)

I'm going to try to explain how I approach a new Angular Project

Clean Repo

@ezequieltejada
ezequieltejada / nodemon-typescript.md
Last active October 1, 2022 21:25
Nodemon & Typescript

Debug with Nodemon and Typescript - Source

When we have our node project in typescript and want to debug we can use VSCode debugger. However we are not willing to sacrifice restarting the server on save or working directly in typescript. How can we achieve that?

Install dependencies

The first step is to install our dev-dependencies. We are going to need:

  • typescript
  • ts-node
  • nodemon
  • @types/node
@ezequieltejada
ezequieltejada / testing-steps.md
Last active July 21, 2022 08:13
Testing Steps
  1. Install Jest (yarn add -D jest babel-jest @babel/core @babel/preset-env | npm install -D jest babel-jest @babel/core @babel/preset-env)
  2. Create babel.config.js file in the root of the project with this content
    module.exports = {
        presets: [
            ['@babel/preset-env', { targets: { node: 'current' } }],
            '@babel/preset-typescript'
        ]
    };
    
@ezequieltejada
ezequieltejada / subscribeExample.ts
Created June 29, 2022 08:14
Handling subscriptions in Angular components
import { Component, OnInit } from '@angular/core';
import { Service } from '../services/service';
@Component({
selector: 'selector-name',
templateUrl: 'name.component.html'
})
export class NameComponent implements OnInit, OnDestroy {
subscriptions$: SubscriptionLike[] = [];
@ezequieltejada
ezequieltejada / sampleREADME.md
Created September 12, 2022 16:36 — forked from FrancesCoronel/sampleREADME.md
A sample README for all your GitHub projects.

Repository Title Goes Here

Frances Coronel

INSERT GRAPHIC HERE (include hyperlink in image)

Subtitle or Short Description Goes Here

ideally one sentence >

@ezequieltejada
ezequieltejada / firebase.json
Created September 27, 2022 10:44
problem with deploy
{
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build",
"npm --prefix \"$RESOURCE_DIR\" run predeploy"