Skip to content

Instantly share code, notes, and snippets.

View Jahans3's full-sized avatar
:shipit:

Josh J Jahans3

:shipit:
View GitHub Profile
import { Dimensions } from 'react-native'
import defaultStyle from '../../style/index'
const { width } = Dimensions.get('window')
export default {
containerWrapper: {
flex: 1
},
import React from 'react'
import PropTypes from 'prop-types'
import { Image, TouchableOpacity } from 'react-native'
import { View, Text } from 'native-base'
import moment from 'moment'
import style from './style'
const Post = ({
author,
interface Car {
void soundHorn(int volume)
void seats(int number)
}
class FordCar implements Car {
int numberOfSeats = 0;
void soundHorn(int volume) {
Sounds.soundHorn(volume);
}
void seats(int number) {
numberOfSeats = number;
}
const Car = Interface('Car')({
seats: type('number'),
passengers: type('array', [type('object', Passenger)]),
beep: type('function')
},{
error: true,
strict: true
})
// ES6 Modules - recommended
import implement, { Interface, type } from 'implement-js'
// CommonJS
const implementjs = require('implement-js')
const implement = implementjs.default
const { Interface, type } = implementjs
const Ford = {
seats: 4,
passengers: { name: 'Bobby', height: 175 },
beep () {
console.log('Beep beep')
},
fuelType: 'diesel'
}
// Bad implementation - throws an error!
const Ford = {
seats: 4,
passengers: [{ name: 'Bobby', height: 175 }, { name: 'Shirley', height: 150 }],
beep () {
console.log('Beep beep')
}
}
const FordCar = implement(Car)(Ford)
const TwitterUser = Interface('TwitterUser')({
twitterId: type('string'),
twitterUsername: type('string')
},{
trim: true,
extends: User,
rename: { twitter_id: 'twitterId', twitter_username: 'twitterUsername' }
})
const getUser = () => async dispatch => {
describe('getCar', () => {
it('should implement the Vehicle Interface', done => {
const someCar = CarService.getCar()
// Ensure someCar implements Vehicle Interface
implement(Vehicle)(someCar)
done()
})
})