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 HocExample = ({ isAtTop }) => { | |
return ( | |
<NavBar | |
isAtTop={isAtTop} | |
info="High Order Component example" | |
/> | |
); | |
}; | |
export default withTopDetector(HocExample); |
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
class PlainExample extends React.Component { | |
state = { | |
isAtTop: true | |
}; | |
componentDidMount() { | |
window.addEventListener("scroll", this.onScrollListener); | |
} | |
componentWillUnmount() { |
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 const withTopDetector = Component => { | |
return class extends React.Component { | |
state = { | |
isAtTop: true | |
}; | |
componentDidMount() { | |
window.addEventListener("scroll", this.onScrollListener); | |
} |
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 winScroll = document.body.scrollTop || document.documentElement.scrollTop; | |
const height = document.documentElement.scrollHeight - document.documentElement.clientHeight; | |
const scrolled = winScroll / height; | |
// scrolled === 0 user is at the top of the page |
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
function getInstanceMethodNames (obj) { | |
return Object | |
.getOwnPropertyNames (Object.getPrototypeOf (obj)) | |
.filter(name => (name !== 'constructor' && typeof obj[name] === 'function')); | |
} | |
function getInstanceStaticMethodNames (Class) { | |
return Object.getOwnPropertyNames(Class) | |
.filter(prop => typeof Class[prop] === "function"); | |
} |
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
package com.bepower.becharge.ui | |
import android.os.Bundle | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.View.OnClickListener | |
import android.view.ViewGroup | |
import androidx.databinding.DataBindingUtil | |
import androidx.databinding.ViewDataBinding | |
import androidx.recyclerview.widget.DiffUtil |
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
/** | |
* | |
* Port of [RemoteData](https://github.com/devexperts/remote-data-ts/blob/master/src/remote-data.ts) | |
* | |
* Represents a value of one of four possible types (a disjoint union) | |
* An instance of [RemoteData] is either an instance of [Initial], [Pending], [Failure] or [Success] | |
* | |
* A common use of [RemoteData] is as an alternative to [Either] or [Option] supporting initial and pending states | |
* | |
* Note: [Initial], [Pending] and [Failure] are commonly called "Left" part. |
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 { Monad2 } from 'fp-ts/lib/Monad' | |
import * as RD from "@devexperts/remote-data-ts" | |
import * as T from "fp-ts/lib/Task" | |
import * as TE from "fp-ts/lib/TaskEither" | |
import * as E from "fp-ts/lib/Either" | |
import { pipe, pipeable } from "fp-ts/lib/pipeable" | |
import { sequenceT } from 'fp-ts/lib/Apply' | |
declare module 'fp-ts/lib/HKT' { | |
interface URItoKind2<E, A> { |
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 { Reader } from 'fp-ts/lib/Reader' | |
import { Monad3 } from 'fp-ts/lib/Monad' | |
import * as RD from "@devexperts/remote-data-ts" | |
import { getReaderM } from 'fp-ts/lib/ReaderT' | |
import { pipeable } from "fp-ts/lib/pipeable" | |
declare module 'fp-ts/lib/HKT' { | |
interface URItoKind3<R, E, A> { | |
ReaderRemoteData: ReaderRemoteData<R, E, A> | |
} |
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 { Reader } from 'fp-ts/lib/Reader' | |
import { Monad3 } from 'fp-ts/lib/Monad' | |
import * as RD from "@devexperts/remote-data-ts" | |
import * as T from "fp-ts/lib/Task" | |
import { monadTaskRemoteData, TaskRemoteData, TRD } from "./TaskRemoteData" | |
import { pipe, pipeable } from "fp-ts/lib/pipeable" | |
import { sequenceT } from 'fp-ts/lib/Apply' | |
declare module 'fp-ts/lib/HKT' { | |
interface URItoKind3<R, E, A> { |
OlderNewer