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 { ObjectType, Field } from 'typegql'; | |
@ObjectType() | |
export class Product { | |
@Field() | |
id: number; | |
@Field() | |
price: 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
import { Schema, Query } from 'typegql'; | |
import { Product } from './product.ts' | |
@Schema() | |
export class FirstSchema { | |
@Query() | |
findProductById(id: number): Product { | |
const foundProduct = new Product(); | |
foundProduct.id = id; | |
foundProduct.price = 90; |
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 * as express from 'express'; | |
import * as graphqlHTTP from 'express-graphql'; | |
import { compileSchema } from 'typegql'; | |
import { FirstSchema } from './simpleSchema.ts' | |
const schema = compileSchema(FirstSchema); | |
const app = express(); |
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
{ | |
findProductById(id: 20) { | |
id | |
price | |
isExpensive | |
} | |
} |
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 { useEffect, useRef } from 'react'; | |
export function useUnmountEffect(callback: () => void) { | |
const callbackRef = useRef(callback); | |
callbackRef.current = callback; | |
useEffect(() => { | |
return () => { | |
const callbackFunction = callbackRef.current; |
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
type AllowedArg = number | string | boolean | null | undefined; | |
function stringifyArg(arg: AllowedArg) { | |
return `${arg}`; | |
} | |
function serializeArgs(args: AllowedArg[]) { | |
const argsLimiter = "<<<<***>>>>"; | |
if (args.length === 0) { |
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
/** | |
* Goal: | |
* | |
* Being able to freeze some part of react tree and stop all updates from 'react word' for part of the tree for some period of time. | |
* It would prevent ui from updating in any way (props change, state change, hooks change etc) | |
* | |
* Use case: | |
* | |
* Let's say there is tab based react-native app. | |
* All of the screens are rendered all the time, and by using some store (redux etc) |
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 { useRef } from 'react'; | |
const noValueSymbol = Symbol(); | |
function didBitsChange(oldBits: any[], newBits: any) { | |
return oldBits.some((oldBit, index) => !Object.is(oldBit, newBits[index])); | |
} | |
export function useSuspend<T>( | |
fetcher: () => Promise<T>, |
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
"Test na mamę" | |
syn rozmawia z mamą o swojej aplikacji. | |
2 przykłady tej rozmowy, jedna w której syn oblewa "test na mamę" i druga w której zalicza. | |
W nawiasach są komentarza autora książki do tego co rozmawiają | |
syn: mamo, mam pomysł na biznes, mogę Ci o tym opowiedzieć? (mama myśli pewnie - o, mój synek! nie chce go urazić!) |