Scala, Functional Programming and Team Productivity7mind
Many engineers spend a lot of time doing repetitive things. In this talk we examine typical productivity issues, which observed in many different companies, and show how to deal with them. We cover:
* Microservices and Monoliths,
* Introspection and Debugging,
* Logging,
* Modular Design,
* Functional Programming,
* RPC and REST,
* Tests and Delivery Pipeline.
This talk is a retrospective of our actions that helped our customer to cut development costs by 50%. We expect our experience to be applicable to most small and medium-sized teams and companies using Scala.
Documentation: https://izumi.7mind.io/latest/release/doc/distage/
Github: https://github.com/pshirshov/izumi-r2
Pavel Shirshov - DIStage: purely functional programming without sacrificing modularity with modern dependency injection for Scala
- Modularity and its importance
- DI-like mechanisms and their issues in Scala
- Why people think that "DI doesn't compose with functional programming", and why that's not true
- Designing a staged DI, for wiring at runtime, at compile-time, or mixed
- Staging programs for reliability, power and performance
- The pains of supporting rich Scala types (incl. How to emulate kind-polymorphism in Scala 2)
- Garbage collection in DI for better tests and deployments
Pavel's bio: Language-agnostic software engineer, coding for 18 years,
10 years of hands-on commercial engineering experience.
Led a cluster orchestration team at Yandex, "the Russian Google"; implemented an internal orchestration solution, "ISS" (Scala/Java/C++), managing 50K+ physical hosts across 6 datacenters.
Today, Pavel owns Irish R&D company Septimal Mind.
Frameworks are bulky, quirky, and non-compositional, which has led to a rejection of Spring and similar frameworks in the Scala ecosystem. Yet, despite their drawbacks, frameworks have been used to boost team productivity in many large companies. In this presentation, Pavel and Kai will introduce Izumi 1.0, a Scala microframework based on compositional functional programming. Designed to help you and your team achieve new levels of productivity, Izumi now includes full compile-time checks for your configurable applications and completely reworked Tagless Final hierarchy for Bifunctors and Trifunctors.
Many Scala developers nowadays consider using Dependency Injection frameworks an anti-pattern incompatible with modern FP settings. We argue that it's just a consequence of a bad experience with legacy Java runtime reflection-based implementations that lack features important for modern functional programming, such as a first-class support for higher-kinded types. We argue that as a paradigm for structuring purely functional programs, DI with automatic wiring compares favorably against implicits, monad transformers, free monads, algebraic effects, cake pattern et al, enabling scaling and a degree of modularity unachievable by any manual wiring approach. This talk covers DIStage – a transparent, flexible and efficient DI framework for Scala that enables late binding, testability, effect separation and modular resource management at scale, working with, instead of compromising the Scala type system.
Documentation: https://izumi.7mind.io/latest/release/doc/distage/
Hyper-pragmatic Pure FP testing with distage-testkit7mind
Having a proper test suite can turn ongoing application maintenance and development into pure joy – the best tests check meaningful properties, not the implementation details, and hold no impliict assumptions about their test environment - every test case must be self-contained and portable. To ensure that tests are free of implementation details and environment dependency, we may simply run them in a different test environment, with different implementations of components. But the boileplate and manual work involved in rewiring components, writing hardcoded fixtures and setting up different test environments make this very hard to do at scale. To tackle this problem we've created distage & distage-testkit, distage-testkit gives you the following superpowers:
* ability to easily swap out individual components or entire test environments
* principled & leak-free control of global resources for integration testing – docker containers, DBs, DDLs
* execute effects or allocate resources per-test, e.g. generate random fixtures per-test
* first-class testing of functional effects
* write tests as lambdas – access test fixtures via parameters or ZIO Environment
...and more! We'll also discuss general testing practices and what really distinguishes good tests from great tests.
Scala, Functional Programming and Team Productivity7mind
Many engineers spend a lot of time doing repetitive things. In this talk we examine typical productivity issues, which observed in many different companies, and show how to deal with them. We cover:
* Microservices and Monoliths,
* Introspection and Debugging,
* Logging,
* Modular Design,
* Functional Programming,
* RPC and REST,
* Tests and Delivery Pipeline.
This talk is a retrospective of our actions that helped our customer to cut development costs by 50%. We expect our experience to be applicable to most small and medium-sized teams and companies using Scala.
Documentation: https://izumi.7mind.io/latest/release/doc/distage/
Github: https://github.com/pshirshov/izumi-r2
Pavel Shirshov - DIStage: purely functional programming without sacrificing modularity with modern dependency injection for Scala
- Modularity and its importance
- DI-like mechanisms and their issues in Scala
- Why people think that "DI doesn't compose with functional programming", and why that's not true
- Designing a staged DI, for wiring at runtime, at compile-time, or mixed
- Staging programs for reliability, power and performance
- The pains of supporting rich Scala types (incl. How to emulate kind-polymorphism in Scala 2)
- Garbage collection in DI for better tests and deployments
Pavel's bio: Language-agnostic software engineer, coding for 18 years,
10 years of hands-on commercial engineering experience.
Led a cluster orchestration team at Yandex, "the Russian Google"; implemented an internal orchestration solution, "ISS" (Scala/Java/C++), managing 50K+ physical hosts across 6 datacenters.
Today, Pavel owns Irish R&D company Septimal Mind.
Frameworks are bulky, quirky, and non-compositional, which has led to a rejection of Spring and similar frameworks in the Scala ecosystem. Yet, despite their drawbacks, frameworks have been used to boost team productivity in many large companies. In this presentation, Pavel and Kai will introduce Izumi 1.0, a Scala microframework based on compositional functional programming. Designed to help you and your team achieve new levels of productivity, Izumi now includes full compile-time checks for your configurable applications and completely reworked Tagless Final hierarchy for Bifunctors and Trifunctors.
Many Scala developers nowadays consider using Dependency Injection frameworks an anti-pattern incompatible with modern FP settings. We argue that it's just a consequence of a bad experience with legacy Java runtime reflection-based implementations that lack features important for modern functional programming, such as a first-class support for higher-kinded types. We argue that as a paradigm for structuring purely functional programs, DI with automatic wiring compares favorably against implicits, monad transformers, free monads, algebraic effects, cake pattern et al, enabling scaling and a degree of modularity unachievable by any manual wiring approach. This talk covers DIStage – a transparent, flexible and efficient DI framework for Scala that enables late binding, testability, effect separation and modular resource management at scale, working with, instead of compromising the Scala type system.
Documentation: https://izumi.7mind.io/latest/release/doc/distage/
Hyper-pragmatic Pure FP testing with distage-testkit7mind
Having a proper test suite can turn ongoing application maintenance and development into pure joy – the best tests check meaningful properties, not the implementation details, and hold no impliict assumptions about their test environment - every test case must be self-contained and portable. To ensure that tests are free of implementation details and environment dependency, we may simply run them in a different test environment, with different implementations of components. But the boileplate and manual work involved in rewiring components, writing hardcoded fixtures and setting up different test environments make this very hard to do at scale. To tackle this problem we've created distage & distage-testkit, distage-testkit gives you the following superpowers:
* ability to easily swap out individual components or entire test environments
* principled & leak-free control of global resources for integration testing – docker containers, DBs, DDLs
* execute effects or allocate resources per-test, e.g. generate random fixtures per-test
* first-class testing of functional effects
* write tests as lambdas – access test fixtures via parameters or ZIO Environment
...and more! We'll also discuss general testing practices and what really distinguishes good tests from great tests.
With these slides you will learn how to build your first functional component and how to get started with React using Webpack and Babel. We will also discover the JSX syntax and by the end of the the slides you will be able to render your first site using React components.
Gradle is a flexible general purpose build system with a build-by-convention framework a la Maven on top. It uses Apache Ivy under the hood for its dependency management. Its build scripts are written in Groovy.
Workshop Apps with ReactNative III:
- React Native short Recap
- The Native Side
- Building Native Modules (iOS & Android)
- Building Native Components (iOS & Android)
Presentado por ingenieros Alberto Irurueta y Enrique Oriol
Advanced Jasmine - Front-End JavaScript Unit TestingLars Thorup
Code: https://github.com/larsthorup/jasmine-demo-advanced
Video: https://www.youtube.com/watch?v=g4eQplHxU18
Audio: https://www.youtube.com/watch?v=8FUwc3gZDMw
Unit testing front-end JavaScript presents its own unique set of challenges. In this session we will look at number of different techniques to tackle these challenges and make our JavaScript unit tests fast and robust. We plan to cover the following subjects:
* Mocking and spy techniques to avoid dependencies on
- Functions, methods and constructor functions
- Time (new Date())
- Timers (setTimeout, setInterval)
- Ajax requests
- The DOM
- Events
* Expressive matchers
- Jasmine-jQuery
* Structuring tests for reuse and readability
* Testing browser-specific behaviour
Test-Driven Development of AngularJS ApplicationsFITC
Save 10% off ANY FITC event with discount code 'slideshare'
See our upcoming events at www.fitc.ca
OVERVIEW
AngularJS is an open-source JavaScript framework, maintained by Google, that simplifies development of single-page applications. This session will provide an overview of AngularJS framework and demonstrate test-driven development of single-page applications.
In this session Andy will present a walkthrough of Angular’s core features such as dependency injector and directives. He will showcase a test-driven development of AngularJS applications using Jasmine and explain Angular’s data bindings that allow for creation of views and controllers that update automatically in response to data changes. He will also demo Angular’s deep linking and front-end validations and present integration with Ruby On Rails back end using AngularJS AJAX abstractions. Finally, Andy will utilize AngularJS directives and components to create reusable UI elements.
In summary, AngularJS is a great framework for creating complex single-page applications. Attendees will leave the talk with a solid understanding of Angular’s test-driven development process.
Have you ever thought how is it to work with ReactJS for a long time? I do. The talk is taking you through the life of the stack at HolidayCheck, lessons learned and other experiences.
With these slides you will learn how to build your first functional component and how to get started with React using Webpack and Babel. We will also discover the JSX syntax and by the end of the the slides you will be able to render your first site using React components.
Gradle is a flexible general purpose build system with a build-by-convention framework a la Maven on top. It uses Apache Ivy under the hood for its dependency management. Its build scripts are written in Groovy.
Workshop Apps with ReactNative III:
- React Native short Recap
- The Native Side
- Building Native Modules (iOS & Android)
- Building Native Components (iOS & Android)
Presentado por ingenieros Alberto Irurueta y Enrique Oriol
Advanced Jasmine - Front-End JavaScript Unit TestingLars Thorup
Code: https://github.com/larsthorup/jasmine-demo-advanced
Video: https://www.youtube.com/watch?v=g4eQplHxU18
Audio: https://www.youtube.com/watch?v=8FUwc3gZDMw
Unit testing front-end JavaScript presents its own unique set of challenges. In this session we will look at number of different techniques to tackle these challenges and make our JavaScript unit tests fast and robust. We plan to cover the following subjects:
* Mocking and spy techniques to avoid dependencies on
- Functions, methods and constructor functions
- Time (new Date())
- Timers (setTimeout, setInterval)
- Ajax requests
- The DOM
- Events
* Expressive matchers
- Jasmine-jQuery
* Structuring tests for reuse and readability
* Testing browser-specific behaviour
Test-Driven Development of AngularJS ApplicationsFITC
Save 10% off ANY FITC event with discount code 'slideshare'
See our upcoming events at www.fitc.ca
OVERVIEW
AngularJS is an open-source JavaScript framework, maintained by Google, that simplifies development of single-page applications. This session will provide an overview of AngularJS framework and demonstrate test-driven development of single-page applications.
In this session Andy will present a walkthrough of Angular’s core features such as dependency injector and directives. He will showcase a test-driven development of AngularJS applications using Jasmine and explain Angular’s data bindings that allow for creation of views and controllers that update automatically in response to data changes. He will also demo Angular’s deep linking and front-end validations and present integration with Ruby On Rails back end using AngularJS AJAX abstractions. Finally, Andy will utilize AngularJS directives and components to create reusable UI elements.
In summary, AngularJS is a great framework for creating complex single-page applications. Attendees will leave the talk with a solid understanding of Angular’s test-driven development process.
Have you ever thought how is it to work with ReactJS for a long time? I do. The talk is taking you through the life of the stack at HolidayCheck, lessons learned and other experiences.
Technologies are ever changing and since we're building our applications on the shoulders of giants like Babel,... We have to stay up-to-date with the newest trends.
We at Codifly strongly believe in using the newest technologies, that's why we've organised a meetup to showcase these for you. This event was organised in collaboration with ITLab HoGent at Campus Schoonmeersen (Voskenslaan 270, 9000 Ghent).
A certain level of knowledge about these subjects is required since we're mostly be going over the recent changes. For Babel we're discussing what's new in their upcoming version 7, for Webpack the changes from 3 -> 4.6 will be discussed and for React all the new features in React 16.3 and the upcoming ones.
React is a UI library that is changing the way web applications are written. While there are many benefits to using React, managing an application's complexity as it scales is one of the most powerful.
Integration testing is hard, and often teams are tempted to do it in production. Testcontainers allows writing meaningful integration tests spawning Docker containers for databases, queue systems, kv-store, other services. The talk, a blend of slides and live code, will show how we are able to deploy without fear while integrating with a dozen of different datastores. Don't mock your database with fake data anymore, work with real data
React Native for multi-platform mobile applicationsMatteo Manchi
Since its 2013 release, React has brought a new way to design UI components in the world wide web. The same foundamentals have been taken to another important environment in our contemporary world: the mobile application.
This month we'll see the philosophy behind React Native - learn once, write anywhere - and how this new framework helps new developers to build native apps using React.
An overview of the code that makes up the skeleton of a basic RCP application. This includes the basics for advisors and perspectives. This module also describes the basics of how to launch and debug an RCP application.
Building cross-platform mobile apps with React Native (Jfokus 2017)Maarten Mulders
There's nothing more expensive than building the same thing twice. Yet that is what a lot of companies do when they publish a mobile app: they build one for Android and one for iOS.
But wait, you don't have to! Using React Native, you can build one mobile app for both platforms from one code base using a language you're probably already familiar with - JavaScript. In this session, we'll discuss building a simple word game app for both iOS and Android. First, we'll dive into how React Native works and how to build a basic application. Then, we'll dive into the Redux framework, which helps us building predictable state and allows for great testability of our application. Finally, we look at how the two integrate and how the game is built.
React Native enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and React. The focus of React Native is on developer efficiency across all the platforms you care about — learn once, write anywhere.
Similar to Making React Native UI Components with Swift (20)
Let's make the real world better together with virtual augmentation. AR is a cool and useful new technology that adds great power to potential applications. And it does not have to be that hard to get into it. We're going to make 3D happen on an iPad in the room. And we're going to do it with JavaScript, using open source software you can use and deploy at home or work.
Attendees will leave with knowledge of 3D programming principles, specifically how AR fits over that, and specific techniques to express 3D virtual objects and scenes in a real-world context on iOS using the react-reality framework for React Native.
Protocol Buffer. HDF5. TFLite. Pickle. They all hold model weights and/or code, and in many cases they can and do hold the same ones. Understanding how they work and how to unpack them outside of our tools gives us insights into how the tools themselves work, and how we can pipe our models around, and make them more useful for our customers - often app developers!
Lightning Talk given at Chain React July 12, 2018. Discussion of advances in applied AI and ML and why React Native developers are uniquely positioned to take advantage.
AI On Your Phone: CoreML and Tensorflow LiteRay Deck
Talk given at Boston CodeCamp 4.7.2018 on applying machine learning models in mobile and small (IoT) devices using CoreML and TensorFlow Lite. Also dicusses common optimization techniques (quantization, pruning) and where the future might go with TensorFlow.js and JS/WebGL in general.
Making Swift Native Modules in React NativeRay Deck
Hooray! XCode 9 allows us to make Swift-based native modules for RN - with just a little help. Learn how and about a tool that makes it easy to create and test your module!
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
3. Why Build a UI Component?
1. Deep Cut
Specific need in an otherwise-available component (visionkit)
2. Native Capabilities
Access to previously-unavailable or new subsystems (AR, VR)
3. Third Party Integration
External functionality to orchestrate through RN (CocoaPods)
10. Takeaways
1. The RCTBridge is the core.
2. There is one bridge module instance per class
per bridge
3. Modules are exposed to the bridge using
objective-C macros (RCT_EXPORT_MODULE,
RCT_EXTERN_MODULE, etc)
12. Takeaways
1. RCTViewManagers are bridge modules, and
follow these rules
2. Views are generated from the ViewManagers
3. RN will control layout and lifecycle of views
emitted from ViewManagers
17. 1. Start with templates from
react-native-swift-cli
2. Open your app as project for
editing
3. Edit or add files in your static
library – not the app proper
4. Use yarn watch to have your
bridge keep up
18. >_ yarn global add react-native-swift-cli
rns init RNBoston ; rns makeapp RNBostonApp RNBoston
cd RNBoston; code .
cd ../RNBostonApp; code . ; react-native xcode
21. Takeaways
1.@objc attribute for code we want to
expose to React native
2.view() is the only method that really
matters
3. requiresMainQueueSetup() should return
false
24. import { BasicView } from “RNBoston”
…
<View style={{height: 90,…}} >
<View style={{ height: 40 }}>
<Text>
Starting with a basic native view. That's the green
thing. Pretty boring.
</Text>
</View>
<BasicView style={{ height: 50, width: "50%" }} />
</View>
25. Takeaways
1.requireNativeComponent exposes the native
view for a React component wrapper
2. You must create a React component that has
the specific job of wrapping the native view
3. React is kind of awesome
28. import Foundation
@objc(RNBostonViewManager)
class RNBostonViewManager: RCTViewManager {
var currentView:RNBostonView?
//MARK: RCTViewManager key methods
override func view() -> RNBostonView {
let newView = RNBostonView()
currentView = newView
return newView
}
override class func requiresMainQueueSetup() -> Bool {
return false;
}
29. Takeaways
1. Using a custom view class to expose props and
manage a nontrivial UX
2. Connect your view to the view manager through a
reference at creation time
3. Use Caution!
30. import UIKit
import AVKit
@objc(RNBostonView)
class RNBostonView: UIView {
//MARK: Private (non-RN-managed) properties
var thisSession = AVCaptureSession?
var previewLayer = AVCaptureVideoPreviewLayer?
var isFront:Bool = false
//MARK: React-native exposed props
@objc var onStart:RCTBubblingEventBlock?
@objc var cameraFront:Bool {
get { return isFront }
set(b) {
isFront = b
AVCaptureDevice.requestAccess(forMediaType: AVMediaTypeVideo) { success in
guard success else { return }
guard
let device = AVCaptureDevice.defaultDevice(withDeviceType: .builtInWideAngleCamera, mediaType:
AVMediaTypeVideo, position: b ? AVCaptureDevice.Position.front : AVCaptureDevice.Position.back),
let input = try? AVCaptureDeviceInput(device: device)
else { return }
let s = AVCaptureSession()
s.addInput(input)
s.startRunning()
guard let pl = AVCaptureVideoPreviewLayer(session: s) else { return }
DispatchQueue.main.async(){
pl.frame = self.bounds
pl.videoGravity = AVLayerVideoGravityResizeAspectFill
self.layer.addSublayer(pl)
self.previewLayer = pl
if let o = self.onStart { o([:]) }
}
}
}
31. @objc(RNBostonView)
class RNBostonView: UIView {
//MARK: Private (non-RN-managed) properties
var thisSession = AVCaptureSession?
var previewLayer = AVCaptureVideoPreviewLayer?
var isFront:Bool = false
//MARK: React-native exposed props
@objc var onStart:RCTBubblingEventBlock?
@objc var cameraFront:Bool {
get { return isFront }
set(b) {
isFront = b
AVCaptureDevice.requestAccess…
32. Takeaways
1. Properties, not methods, are exposed.
2. Properties can be simple “var” declarations or use
get/set pattern
3. Cheat lifecycle events with prop setters
4. Function props are RCTBubblingEventBlocks
5. Declare RCTBubblingEventBlocks as optional (using ?)
37. import Foundation
@objc(RNBostonViewManager)
class RNBostonViewManager: RCTViewManager {
var currentView:RNBostonView?
//MARK: RCTViewManager key methods
override func view() -> RNBostonView {
let newView = RNBostonView()
currentView = newView
return newView
}
override class func requiresMainQueueSetup() -> Bool {
return false;
}
38. @objc(RNBostonViewManager)
class RNBostonViewManager: RCTViewManager,
AVCapturePhotoCaptureDelegate {
…
@objc func takePicture(_ resolve:@escaping
RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) {
guard let view = currentView else { reject("no_view",
"No view loaded", nil); return }
guard let session = view.thisSession else {
reject("no_session", "No AV capture session running", nil);
return }
if let p = self.photoOutput {
session.removeOutput(p)
self.photoOutput = nil
39. Takeaways
1. The ViewManager is a Native Module!
2. Add native module methods to add imperative
logic to your view
3. Use promises (RCTPromiseResolveBlock and
RCTPromiseRejectBlock) to return data
4. Give your app superpowers!