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
expect(reduce(['change', 'input-01', 'ball'], initialState)).toEqual({ | |
input: "ball", | |
isInStockOnly: false, | |
products: [ | |
{ | |
id: "0", | |
category: "Sporting Goods", | |
price: "$49.99", | |
stocked: true, | |
name: "Football", |
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
const initialState: IState = { | |
input: "", | |
isInStockOnly: false, | |
products: [ | |
{ | |
id: "0", | |
category: "Sporting Goods", | |
price: "$49.99", | |
stocked: true, | |
name: "Football" |
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 React from "react"; | |
import { Subject } from "rxjs"; | |
export type EventType = "click" | "change" | "focus"; | |
export type Id = string; | |
export type IEvent = [EventType, Id, string | undefined]; | |
export const EventSubject = new Subject<IEvent>(); | |
export const EventWrapper: React.FC<{ id: string }> = (props) => { |
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
const is = (it, n = Symbol()) => (it ?? n) !== n; | |
const is = it => (it ?? null) !== null; |
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
git branch | grep -v "master" | xargs git branch -D |
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
const isPristine = ( | |
fieldName: string | string[], | |
touched: FormikTouched<FormikValues> | |
) => | |
[fieldName] | |
.flatMap((fieldName) => fieldName) | |
.every((fieldName) => !touched[fieldName]); |
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 { Subject } from "rxjs"; | |
import { RTCMessagingAgent } from "./rtc-messaging-agent"; | |
const configuration = { | |
iceServers: [ | |
{ | |
urls: [ | |
"stun:stun.l.google.com:19302", | |
"stun:stun1.l.google.com:19302", | |
"stun:stun2.l.google.com:19302", |
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 class RTCMessagingAgent { | |
// Subjects | |
public OnAddParticipantSubject = new Subject<string>(); | |
public OnRemoveParticipantSubject = new Subject<string>(); | |
public OnSetLocalDescription = new Subject< | |
[string, RTCSessionDescriptionInit] | |
>(); | |
public OnSetRemoteDescription = new Subject< | |
[string, RTCSessionDescriptionInit] |
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 class BroadcastingAgent { | |
// Participants | |
public participants: string[] = []; | |
// Subjects | |
public addParticipantSubject = new Subject<string>(); | |
public removeParticipantSubject = new Subject<string>(); | |
private commSubject: Subject<IMessage<unknown>>; | |
constructor( |
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 class Client { | |
private id = generateId(4, 4); | |
// Channels | |
private dataChannels: { [id: string]: RTCDataChannel } = {}; | |
private streams: { [id: string]: MediaStream[] } = {}; | |
// Agents | |
private BroadcastingAgent = new BroadcastingAgent( | |
this.id, |