This file contains hidden or 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
| describe('getCar', () => { | |
| it('should implement the Vehicle Interface', done => { | |
| const someCar = CarService.getCar() | |
| // Ensure someCar implements Vehicle Interface | |
| implement(Vehicle)(someCar) | |
| done() | |
| }) | |
| }) |
This file contains hidden or 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 TwitterUser = Interface('TwitterUser')({ | |
| twitterId: type('string'), | |
| twitterUsername: type('string') | |
| },{ | |
| trim: true, | |
| extends: User, | |
| rename: { twitter_id: 'twitterId', twitter_username: 'twitterUsername' } | |
| }) | |
| const getUser = () => async dispatch => { |
This file contains hidden or 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 Ford = { | |
| seats: 4, | |
| passengers: [{ name: 'Bobby', height: 175 }, { name: 'Shirley', height: 150 }], | |
| beep () { | |
| console.log('Beep beep') | |
| } | |
| } | |
| const FordCar = implement(Car)(Ford) |
This file contains hidden or 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 Ford = { | |
| seats: 4, | |
| passengers: { name: 'Bobby', height: 175 }, | |
| beep () { | |
| console.log('Beep beep') | |
| }, | |
| fuelType: 'diesel' | |
| } | |
| // Bad implementation - throws an error! |
This file contains hidden or 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
| // ES6 Modules - recommended | |
| import implement, { Interface, type } from 'implement-js' | |
| // CommonJS | |
| const implementjs = require('implement-js') | |
| const implement = implementjs.default | |
| const { Interface, type } = implementjs |
This file contains hidden or 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 Car = Interface('Car')({ | |
| seats: type('number'), | |
| passengers: type('array', [type('object', Passenger)]), | |
| beep: type('function') | |
| },{ | |
| error: true, | |
| strict: true | |
| }) |
This file contains hidden or 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 FordCar implements Car { | |
| int numberOfSeats = 0; | |
| void soundHorn(int volume) { | |
| Sounds.soundHorn(volume); | |
| } | |
| void seats(int number) { | |
| numberOfSeats = number; | |
| } |
This file contains hidden or 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
| interface Car { | |
| void soundHorn(int volume) | |
| void seats(int number) | |
| } |
This file contains hidden or 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 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, |
This file contains hidden or 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 { Dimensions } from 'react-native' | |
| import defaultStyle from '../../style/index' | |
| const { width } = Dimensions.get('window') | |
| export default { | |
| containerWrapper: { | |
| flex: 1 | |
| }, |