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
/* eslint-disable @typescript-eslint/no-unused-vars */ | |
// Reading | |
// Narrowing - https://www.typescriptlang.org/docs/handbook/2/narrowing.html | |
// Generics - https://www.typescriptlang.org/docs/handbook/2/functions.html#generic-functions | |
// Assignment | |
// Create a function executeHttpRequest that takes an argument of type HttpOptions (from the previous assignment) or a string representing a URL. | |
// - The function should return a Promise that resolves to a generic type T, which defaults to string. | |
// - If the argument is a string, it should be treated as a URL and the function should perform a GET request to that URL. | |
// - If the argument is of type HttpOptions, it should perform an HTTP request based on the provided options. |
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
// Reading | |
// Union Types - https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types | |
// Literal Types - https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types | |
// Discriminated Uninons - https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions | |
// Assignemnt | |
// Create a type HttpOptions that represents options for an HTTP request. | |
// The type should include: | |
// - A required url property of type string. | |
// - An optional headers property which is an object with string keys and string values. |
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 Mutation{ | |
createEntry(entry: Entry!):EntryOutput! | |
} | |
input Entry { | |
geoToken: String! | |
amount: Float! | |
userId: String | |
picks: [Pick!]! | |
} |
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 React, { Component, PureComponent, useState } from 'react'; | |
import { | |
Text, | |
StyleSheet, | |
View, | |
Button, | |
TouchableHighlight, | |
} from 'react-native'; | |
export const Counters = () => { |
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
... | |
render() { | |
return ( | |
<View> | |
... | |
<CounterDisplay | |
style={styles.counter1} | |
value={this.state.counter1} | |
onPress={this.onCounterPress} | |
/> |
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
... | |
<CounterDisplay | |
style={styles.counter1} | |
value={this.state.counter1} | |
onPress={value => alert(value)} | |
/> | |
<CounterDisplay | |
style={styles.counter2} | |
value={this.state.counter2} | |
onPress={value => alert(value)} |
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
... | |
<CounterDisplay style={styles.counter1} value={this.state.counter1} /> | |
<CounterDisplay style={styles.counter2} value={this.state.counter2} /> | |
... | |
const styles = StyleSheet.create({ | |
counter1: { width: 50, alignItems: "center", backgroundColor: "red" }, | |
counter2: { width: 50, alignItems: "center", backgroundColor: "yellow" } | |
}); |
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
class CounterDisplay extends Component { | |
render() { | |
return ( | |
<View {...this.props}> | |
<Text>{this.props.value}</Text> | |
</View> | |
); | |
} | |
} | |
... |
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
export class Counters extends Component { | |
state = { | |
counter1: 0, | |
counter2: 0 | |
}; | |
render() { | |
return ( | |
<View> | |
<Button | |
title={"Increase counter 1"} |
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
Flowable.combineLatest( | |
locationStream.filter { it.accuracy < 20 }, | |
azimuthStream, | |
combineLocationAndAzimuth()) | |
.throttleLast(5, TimeUnit.SECONDS) | |
.flatMap { userData -> restApi.postUserData(userData) } | |
.subscribeOn(Schedulers.io()) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe({ | |
//API response received |
NewerOlder