Upload
kevin-oneill
View
310
Download
2
Embed Size (px)
Citation preview
kevin o’neillemail: [email protected] twitter: @kevinoneill
kevin o’neillemail: [email protected] twitter: @kevinoneill
building mobile applications that delight users is hard
kevin o’neillemail: [email protected] twitter: @kevinoneill
building mobile applications for multiple platforms
that delight users is harder
kevin o’neillemail: [email protected] twitter: @kevinoneill
choices
kevin o’neillemail: [email protected] twitter: @kevinoneill
native development
kevin o’neillemail: [email protected] twitter: @kevinoneill
platform feel raw performance
full platform integration
kevin o’neillemail: [email protected] twitter: @kevinoneill
the challenge ofnative development
kevin o’neillemail: [email protected] twitter: @kevinoneill
slow development cycles slow deployment cycles
multiple languagesmultiple api’s
kevin o’neillemail: [email protected] twitter: @kevinoneill
cross platform development
kevin o’neillemail: [email protected] twitter: @kevinoneill
quick development cycles quick deployment cycles
single languagesingle api*
kevin o’neillemail: [email protected] twitter: @kevinoneill
the challenge ofcross platform development
kevin o’neillemail: [email protected] twitter: @kevinoneill
poor performance poor Feel
lowest denominator
kevin o’neillemail: [email protected] twitter: @kevinoneill
and neither approach
kevin o’neillemail: [email protected] twitter: @kevinoneill
helps you manage the growing complexity of modern mobile
applications
kevin o’neillemail: [email protected] twitter: @kevinoneill
introducingreact native
kevin o’neillemail: [email protected] twitter: @kevinoneill
slow development cycles hot reload
kevin o’neillemail: [email protected] twitter: @kevinoneill
slow deployment cycles direct ota updates
kevin o’neillemail: [email protected] twitter: @kevinoneill
multiple languges es6/7 javaScript core
kevin o’neillemail: [email protected] twitter: @kevinoneill
multiple api’s 90% of the api’s are shared
between platforms
kevin o’neillemail: [email protected] twitter: @kevinoneill
poor performance native corevirtual dom
kevin o’neillemail: [email protected] twitter: @kevinoneill
poor feel native ui and interactions
kevin o’neillemail: [email protected] twitter: @kevinoneill
lowest denominator split between platforms where
distinction is required
kevin o’neillemail: [email protected] twitter: @kevinoneill
react native
kevin o’neillemail: [email protected] twitter: @kevinoneill
a native core with modern javascript
a functional ui and flexbox layout
kevin o’neillemail: [email protected] twitter: @kevinoneill
the ui is pure native not a UIWebView bridge
a native core
kevin o’neillemail: [email protected] twitter: @kevinoneill
utilises a ‘message bus’for communication between
application logic and the native ui
kevin o’neillemail: [email protected] twitter: @kevinoneill
creating your own native modules is trivial
kevin o’neillemail: [email protected] twitter: @kevinoneill
bridging modules@interface CalendarManager : NSObject <RCTBridgeModule> @end
@implementation CalendarManager RCT_EXPORT_MODULE()
RCT_EXPORT_METHOD( addEvent:(NSString *)name location:(NSString *)location) { RCTLogInfo(@"Pretending to create an event %@ at %@", name, location); } @end
kevin o’neillemail: [email protected] twitter: @kevinoneill
bridging modules
import { CalendarManager } from ‘NativeModules';
CalendarManager.addEvent(‘React Native Talk', 'NAB');
kevin o’neillemail: [email protected] twitter: @kevinoneill
bridging native views
@interface MapManager : RCTViewManager <MKMapViewDelegate> @end
@implementation MapManager RCT_EXPORT_MODULE() - (UIView *)view { return [[MKMapView alloc] init]; } @end
kevin o’neillemail: [email protected] twitter: @kevinoneill
bridging native views
import React from ‘react-native';
let { requireNativeComponent } = React;
export default requireNativeComponent(‘Map', null);
kevin o’neillemail: [email protected] twitter: @kevinoneill
bridging native views
import React from 'react-native';
let { requireNativeComponent } = React;
export default requireNativeComponent(‘Map', null);
kevin o’neillemail: [email protected] twitter: @kevinoneill
the majority of the time you wont be concerned with the bridge
kevin o’neillemail: [email protected] twitter: @kevinoneill
events- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
MKCoordinateRegion region = mapView.region; NSDictionary *event = @{ @“center": { @"lat": @(region.center.latitude), @"long": @(region.center.longitude) }}; [self.bridge.eventDispatcher sendInputEventWithName:@"centerChanged" body:event];}
kevin o’neillemail: [email protected] twitter: @kevinoneill
eventsclass MapView extends React.Component { constructor() { this._onChange = this._onChange.bind(this); }
_onChange(event: Event) { if (!this.props.onCenterChange) { return; } this.props.onCenterChange(event.nativeEvent.center); } render() {
return <Map onChange={this._onChange} />; }
}
kevin o’neillemail: [email protected] twitter: @kevinoneill
es 6/7 modern javascript
kevin o’neillemail: [email protected] twitter: @kevinoneill
babel a javascript compiler
kevin o’neillemail: [email protected] twitter: @kevinoneill
es6• Arrow functions: <C onPress={() => this.setState({pressed: true})}• Block scoping: let greeting = 'hi';• Call spread: Math.max(...array);• Classes: class C extends React.Component { render() { return <View />; } }
• Constants: const answer = 42;• Destructuring: var {isActive, style} = this.props;• Modules: import React, { Component } from 'react-native';• Computed Properties: var key = 'abc'; var obj = {[key]: 10};• Object Consise Method: var obj = { method() { return 10; } };• Object Short Notation: var name = 'vjeux'; var obj = { name };• Rest Params: function(type, ...args) { }• Template Literals: var who = 'world'; var str = `Hello ${who}`;
kevin o’neillemail: [email protected] twitter: @kevinoneill
es7
• Object Spread: var extended = { ...obj, a: 10 };• Function Trailing Comma: function f(a, b, c,) { }• Async Functions: async function doStuffAsync() { const foo = await doOtherStuffAsync(); };
kevin o’neillemail: [email protected] twitter: @kevinoneill
jsx markup in javascript
kevin o’neillemail: [email protected] twitter: @kevinoneill
it’s clearer to work with markup than raw
javascript
kevin o’neillemail: [email protected] twitter: @kevinoneill
jsxrender() { const movie = this.props.movie; return ( <View style={styles.container}> <Text>{movie.title}</Text> <Text>{movie.year}</Text> <Image source={{uri: movie.posters.thumbnail}} /> </View> ); }
kevin o’neillemail: [email protected] twitter: @kevinoneill
isn’t mixing layout and logic bad
kevin o’neillemail: [email protected] twitter: @kevinoneill
other toolsflow, typescript, redux …
kevin o’neillemail: [email protected] twitter: @kevinoneill
define states, not transitionsfunctional ui
kevin o’neillemail: [email protected] twitter: @kevinoneill
describing transitions
kevin o’neillemail: [email protected] twitter: @kevinoneill
describing states
kevin o’neillemail: [email protected] twitter: @kevinoneill
the view hierarchy is recalculated for every state change
kevin o’neillemail: [email protected] twitter: @kevinoneill
the virtual dom
kevin o’neillemail: [email protected] twitter: @kevinoneill
describes the view hierarchy
kevin o’neillemail: [email protected] twitter: @kevinoneill
recalculated on state change
kevin o’neillemail: [email protected] twitter: @kevinoneill
differences used to patch the ui
kevin o’neillemail: [email protected] twitter: @kevinoneill
stacked views on steroids flexbox layout
kevin o’neillemail: [email protected] twitter: @kevinoneill
containers
kevin o’neillemail: [email protected] twitter: @kevinoneill
columns
kevin o’neillemail: [email protected] twitter: @kevinoneill
center
kevin o’neillemail: [email protected] twitter: @kevinoneill
space around
kevin o’neillemail: [email protected] twitter: @kevinoneill
space between
kevin o’neillemail: [email protected] twitter: @kevinoneill
wrapping
kevin o’neillemail: [email protected] twitter: @kevinoneill
proportional sizing
kevin o’neillemail: [email protected] twitter: @kevinoneill
plus content alignment, self alignment and more
kevin o’neillemail: [email protected] twitter: @kevinoneill
i liked flexBox so muchi created a swift version
kevin o’neillemail: [email protected] twitter: @kevinoneill
kevin o’neillemail: [email protected] twitter: @kevinoneill
Closing Thoughts
kevin o’neillemail: [email protected] twitter: @kevinoneill
react makes it easier to reason about application state
kevin o’neillemail: [email protected] twitter: @kevinoneill
it’s not a cure all
kevin o’neillemail: [email protected] twitter: @kevinoneill
it’s under active developmentand sometimes unstable
kevin o’neillemail: [email protected] twitter: @kevinoneill
facebook groups and pages are built on it
kevin o’neillemail: [email protected] twitter: @kevinoneill
it’s not an all or nothing proposition
kevin o’neillemail: [email protected] twitter: @kevinoneill
until now i’ve been a pure native developer
kevin o’neillemail: [email protected] twitter: @kevinoneill
it allows rapid iterationon your product ideas
kevin o’neillemail: [email protected] twitter: @kevinoneill
it’s a cornerstone technologyfor my new startup
kevin o’neillemail: [email protected] twitter: @kevinoneill
Thank you Questions?