Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Sullivan alexsullivan114

View GitHub Profile
View ExampleJsx.tsx
const FeatureLayer = ({ id, circular }: { id: string; circular: boolean }) => {
if (circular) {
return (
<MapboxGL.CircleLayer
id={`${id}-circle`}
style={{ circleRadius: 500, circleColor: "black" }}
/>
)
} else {
return (
View UsernameSarchViewModel.kt
class UsernameSearchViewModel(
api: CostarApi,
schedulersContainer: SchedulersContainer,
analytics: Analytics
) : ViewModel() {
enum class VisibleSearchComponent { Loading, List, EmptyMessage }
private val minCharacterCount = 3
private val disposables = CompositeDisposable()
View ExampleTest.kt
@Test
fun `An invalid message is sent if a user inputs an invalid password`() {
val api = mockk<CostarApi>()
val remoteConfig = mockk<RemoteConfig>()
every { api.validatePassword(any()) } returns Single.just(Invalid(listOf(PasswordLengthShouldGT6)))
every { remoteConfig.getString(validation_password_too_short) } returns "Too short"
val viewModel = buildViewModel(api, remoteConfig = remoteConfig)
viewModel.newPasswordInput("test")
View stuff.kt
class AddNoteActivity : BaseActivity<AddNoteViewModel>() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_add_note)
add_note_button.setOnClickListener { viewModel.addNoteClicked(note_text.text.toString()) }
observeTrigger(viewModel.setResultAndFinishStream, this::setResultAndFinish)
observeTrigger(viewModel.showAddNoteFailedErrorStream, this::showErrorMessage)
observe(viewModel.shouldEnableAddNoteButtonStream, add_note_button::setEnabled)
View BaseballStateMachine.kt
class GameStateMachine(
events: Flowable<Event>,
gameStateManager: GameStateManager,
playHarvester: PlayHarvesterImpl
) {
private var state: GameStateMachineState =
BatterUpState(GameCoordinator(gameStateManager, playHarvester))
val viewStates: Flowable<ViewState> = Flowable.just(state.viewState).concatWith(events
@alexsullivan114
alexsullivan114 / new_way.tsx
Last active Oct 19, 2018
Moving from the old Android permissions model to the new permissions model in React Native.
View new_way.tsx
export default class ContactsDisplay extends Component {
render() {
return (
<View>
<Button title="Press me for contacts!" onPress={this.getContacts} />
</View>
)
}
async requestContactsPermission() {
You can’t perform that action at this time.