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
All of this evidence demonstrates that reddit the company seems like a welcoming community, but the key to their success lies in | |
how reddit the website is good at developing the feeling of community. This is achieved by the subreddit system, which lets any | |
user create a new subreddit for users to submit links to. Two months into the founding of reddit, the two co-founders, Alexis | |
Ohanian and Steve Huffman, had an argument over how to let people categorize their submissions to reddit.com. Their two | |
candidates were searchable tags, which were very popular athte time, and subreddits, a system where users could make their own | |
subsections of the site to submit to. The concept which Huffman said to Ohanian to explain the purpose of subreddits was: | |
Let’s say somebody submits a story about how the Nets aren’t doing well and we’re using the tag system. “Nets not performing up | |
to pre-season expectations this year. #Nets #Brooklyn #NYC #NBA” The problem is that each of those groups could have a | |
completely differe |
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 guard; only returns `true` if object shape has a non-null | |
* `data` value and `err` has a null value. | |
* @param val | |
*/ | |
export function isSuccessResponse(val:any): val is SuccessResponse { | |
return ( | |
isObject(val) && | |
val.data && | |
val.err === 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
export function LoginScreen(props) { | |
const [loginArgs, setLoginArgs] = React.useState(Login.newArgs()); | |
async function submitLogin() { | |
const res:Login.Response = await DappbotAPI.auth.login.call(loginArgs); | |
... | |
} | |
return ( | |
... |
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 AllStripeTypes from 'stripe'; | |
export namespace StripeTypes { | |
export type Customer = AllStripeTypes.customers.ICustomer; | |
export type Card = AllStripeTypes.ICard; | |
export type Subscription = AllStripeTypes.subscriptions.ISubscription; | |
export type SubscriptionState = AllStripeTypes.subscriptions.SubscriptionStatus; | |
export type Invoice = AllStripeTypes.invoices.IInvoice; |
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 API from '@eximchain/dappbot-api-client'; | |
import Payment, { StripeTypes } from '@eximchain/dappbot-types/spec/methods/payment'; | |
// Nested namespaces make for legible collision-free names | |
const res:Payment.Read.Response = await API.payment.read.call(); | |
// Helper namespace cuts down on extra text | |
const subscription:StripeTypes.Subscription = res.data.subscription; |
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 { XOR } from 'ts-xor'; | |
import { ApiResponse } from '../../responses'; | |
export namespace Login { | |
export const HTTP:HttpMethods.POST = 'POST'; | |
export const Path = `${authBasePath}/${ResourcePaths.login}` | |
export interface Args { | |
username: string, |
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 { Login } from '@eximchain/dappbot-types/spec/methods/auth'; | |
import request from 'request-promise-native'; | |
const baseApiUrl = 'https://api.dapp.bot'; | |
async function loginToDappbot(creds:Login.Args):Login.Result { | |
const res:Login.Response = await request({ | |
headers : { 'Content-Type' : 'application/json' }, | |
method : Login.HTTP, |
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 interface SomeData { | |
foo: string | |
bar: string | |
} | |
export function newSomeData(): SomeData { | |
return { | |
foo: 'example', | |
bar: 'object' | |
} |
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
// The type reference is so wordy! This isn't convenient. | |
import Types from '@eximchain/dappbot-types'; | |
const args: Types.Methods.Auth.Login.Args = { ... }; | |
// We can make the reference more compact by importing a | |
// more specific slice of the overall types. | |
import Auth from '@eximchain/dappbot-types/spec/methods'; | |
const args: Auth.Login.Args = { ... }; |
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
// This line takes all of the exports from that | |
// file and wraps them into a single namespace. | |
// If we didn't do this "* as User" syntax here, | |
// then a consumer would have to do it in order | |
// to get a convenient namespace. | |
import * as User from './user'; | |
// This line directly surfaces all of its non-default | |
// exports from right here, so that users can just | |
// grab one item from there, e.g.: |
OlderNewer