-
redux is a global
data
management tool, not a properstate
management tool, hence causing a lot of troubles -
statecharts is an extension to Finite State Machine (FSM) which provides explicit and safe state management capabilities, perfectly fit for front-end development
-
statecharts had been used intensivelly in all industries (be it embedded systems, hardware, electronics, aeronautics, automotive, game development and more), it's us front-end developers late to the party
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
type ResponseWithData = Response & { data?: any }; | |
interface Fetcher { | |
run(input: RequestInfo, init?: RequestInit): Promise<ResponseWithData>; | |
} | |
class BasicFetcher implements Fetcher { | |
async run(input: RequestInfo, init?: RequestInit): Promise<ResponseWithData> { | |
return await fetch(input, init); | |
} |
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
struct ReviewTabView: View { | |
var reviews: [Review] = [ | |
Review(title: "Great app", reviewer: "Maartje Derks", text: "This app really makes my life so much easier. Can't wait to use it."), | |
Review(title: "Great app", reviewer: "Maartje Derks", text: "This app really makes my life so much easier. Can't wait to use it."), | |
Review(title: "Great app", reviewer: "Maartje Derks", text: "This app really makes my life so much easier. Can't wait to use it."), | |
Review(title: "Great app", reviewer: "Maartje Derks", text: "This app really makes my life so much easier. Can't wait to use it."), | |
] | |
@State var selectedIndex = 0 | |
@State var timer = Timer.publish(every: 4, on: .main, in: .common).autoconnect() |
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 { createContext, useContext, useReducer, Dispatch } from 'react'; | |
/** | |
* Manages the state for our entire app | |
* | |
** For larger, more complex applications, this pattern can be split into multiiple contexts. | |
** For example: `form`, and `user` would have theor own contexts, each with their own reducer. | |
*/ | |
// Init an empty context |
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 SwiftUI | |
import PlaygroundSupport | |
struct app: View { | |
var appTitle: String | |
var appDesc: String | |
var appColor: Color | |
var body: some View { | |
HStack (alignment: .center, spacing: 14) { | |
VStack { |
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 { async, ComponentFixture, TestBed } from '@angular/core/testing'; | |
import { HistoryComponent } from './history.component'; | |
fdescribe('HistoryComponent', () => { | |
let component: HistoryComponent; | |
let fixture: ComponentFixture<HistoryComponent>; | |
beforeEach(async(() => { | |
TestBed.configureTestingModule({ |
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 { Pipe, PipeTransform } from '@angular/core'; | |
import { isObservable, of } from 'rxjs'; | |
import { map, startWith, catchError } from 'rxjs/operators'; | |
@Pipe({ | |
name: 'withLoading', | |
}) | |
export class WithLoadingPipe implements PipeTransform { | |
transform(val) { | |
return isObservable(val) |
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
/** | |
* @name mapToObject | |
* @desc Converts Map to Object | |
* @param {Map} map | |
* @returns {Object} | |
*/ | |
function mapToObject(map) { | |
return Object.assign(Object.create(null), ...[...map].map(v => ({ [v[0]]: v[1] }))); | |
} |
How to unstar all your github stars with API
visit here: https://github.com/settings/tokens
make sure to check repo
scope, it is needed to unstar
A quick cheatsheet of useful snippet for Flutter
A widget is the basic type of controller in Flutter Material.
There are two type of basic Widget we can extend our classes: StatefulWidget
or StatelessWidget
.
StatefulWidget are all the widget that interally have a dynamic value that can change during usage. It can receive an input value in the constructor or reference to functions. You need to create two classes like:
NewerOlder