Skip to content

Instantly share code, notes, and snippets.

View alexsullivan114's full-sized avatar

Alex Sullivan alexsullivan114

  • Boston
View GitHub Profile
@alexsullivan114
alexsullivan114 / ExampleJsx.tsx
Created November 26, 2019 16:04
JSX Confusion
const FeatureLayer = ({ id, circular }: { id: string; circular: boolean }) => {
if (circular) {
return (
<MapboxGL.CircleLayer
id={`${id}-circle`}
style={{ circleRadius: 500, circleColor: "black" }}
/>
)
} else {
return (
class UsernameSearchViewModel(
api: CostarApi,
schedulersContainer: SchedulersContainer,
analytics: Analytics
) : ViewModel() {
enum class VisibleSearchComponent { Loading, List, EmptyMessage }
private val minCharacterCount = 3
private val disposables = CompositeDisposable()
@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")
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)
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 October 19, 2018 14:57
Moving from the old Android permissions model to the new permissions model in React Native.
export default class ContactsDisplay extends Component {
render() {
return (
<View>
<Button title="Press me for contacts!" onPress={this.getContacts} />
</View>
)
}
async requestContactsPermission() {