RxJs - demystified provides an overview of reactive programming and RxJs. The key points covered are:
- Reactive programming focuses on propagating changes without explicitly specifying how propagation happens.
- Observables are at the heart of RxJs and emit values in a push-based manner. Operators allow transforming, filtering, and combining observables.
- Common operators include map, filter, reduce, buffer, and switchMap. Over 120 operators exist for tasks like error handling, multicasting, and conditional logic.
- Marble diagrams visually demonstrate how operators transform observable streams.
- Creating observables from events, promises, arrays and iterables allows wrapping different data sources in a uniform API
RxJS is a library for reactive programming that allows composing asynchronous and event-based programs using observable sequences. It provides the Observable type for pushing multiple values to observers over time asynchronously. Operators allow transforming and combining observables. Key types include Observable, Observer, Subject, BehaviorSubject, and ReplaySubject. Subjects can multicast values to multiple observers. Overall, RxJS is useful for handling asynchronous events as collections in a declarative way.
Here I discuss about reactive programming, observable, observer and difference between observable and promise.
Also discuss some of important operators like forkJoin, switchMap, from, deboucneTime, discardUntilChanged, mergeMap. I discuss some of observable creation function.
Angular & RXJS: examples and use casesFabio Biondi
The document discusses using RxJS in Angular applications. It provides examples of using RxJS operators like interval, map, async pipe, filter, switchMap, exhaustMap, tap, scan, and reduce. Common use cases include handling events, making HTTP requests, managing application state, and manipulating data. RxJS can be used in components, directives, services, routing, forms, and more throughout an Angular application.
The document discusses the benefits of using RxJS observables over promises and events for managing asynchronous and reactive code in Angular applications. It explains key concepts like observers, subscriptions, operators, cold vs hot observables, and using RxJS with services and components. Example code is provided for creating observable data services to share data between components, composing asynchronous logic with operators, and best practices for managing subscriptions and preventing memory leaks. Overall, the document promotes a reactive programming style with RxJS for building maintainable and testable Angular applications.
This document summarizes the new features and goals of RxJS version 5, which aims to improve the modularity, performance, debugging, and extensibility of the RxJS library. Key changes include making RxJS fully modular, improving performance by reducing allocations and call stack sizes, enhancing debugging with simpler operator implementations, and allowing better extensibility through subclassing Observables and maintaining Subject bi-directionality. Simpler unit tests using marble diagrams are also highlighted.
React Router is the most widely used router for React, in use by almost half of all React projects. This talk is about using React Router in your project. It will start with the basics and will go through all features React Router has to offer in the current version and the upcoming 1.0 release. I will also go through some common problems including data fetching and authentication.
RxJS is a library for reactive programming that allows composing asynchronous and event-based programs using observable sequences. It provides the Observable type for pushing multiple values to observers over time asynchronously. Operators allow transforming and combining observables. Key types include Observable, Observer, Subject, BehaviorSubject, and ReplaySubject. Subjects can multicast values to multiple observers. Overall, RxJS is useful for handling asynchronous events as collections in a declarative way.
Here I discuss about reactive programming, observable, observer and difference between observable and promise.
Also discuss some of important operators like forkJoin, switchMap, from, deboucneTime, discardUntilChanged, mergeMap. I discuss some of observable creation function.
Angular & RXJS: examples and use casesFabio Biondi
The document discusses using RxJS in Angular applications. It provides examples of using RxJS operators like interval, map, async pipe, filter, switchMap, exhaustMap, tap, scan, and reduce. Common use cases include handling events, making HTTP requests, managing application state, and manipulating data. RxJS can be used in components, directives, services, routing, forms, and more throughout an Angular application.
The document discusses the benefits of using RxJS observables over promises and events for managing asynchronous and reactive code in Angular applications. It explains key concepts like observers, subscriptions, operators, cold vs hot observables, and using RxJS with services and components. Example code is provided for creating observable data services to share data between components, composing asynchronous logic with operators, and best practices for managing subscriptions and preventing memory leaks. Overall, the document promotes a reactive programming style with RxJS for building maintainable and testable Angular applications.
This document summarizes the new features and goals of RxJS version 5, which aims to improve the modularity, performance, debugging, and extensibility of the RxJS library. Key changes include making RxJS fully modular, improving performance by reducing allocations and call stack sizes, enhancing debugging with simpler operator implementations, and allowing better extensibility through subclassing Observables and maintaining Subject bi-directionality. Simpler unit tests using marble diagrams are also highlighted.
React Router is the most widely used router for React, in use by almost half of all React projects. This talk is about using React Router in your project. It will start with the basics and will go through all features React Router has to offer in the current version and the upcoming 1.0 release. I will also go through some common problems including data fetching and authentication.
Rxjs provides a paradigm for dealing with asynchronous operations in a way that resembles synchronous code. It uses Observables to represent asynchronous data streams over time that can be composed using operators. This allows handling of events, asynchronous code, and other reactive sources in a declarative way. Key points are:
- Observables represent asynchronous data streams that can be subscribed to.
- Operators allow manipulating and transforming streams through methods like map, filter, switchMap.
- Schedulers allow controlling virtual time for testing asynchronous behavior.
- Promises represent single values while Observables represent continuous streams, making Observables more powerful for reactive programming.
- Cascading asynchronous calls can be modeled elegantly using switch
Talk given at DevTeach Montreal on RxJS - The Basics & The Future.
Example repo: https://github.com/ladyleet/rxjs-test
Have questions? Find me on twitter http://twitter.com/ladyleet
RxJS Operators - Real World Use Cases (FULL VERSION)Tracy Lee
This document provides an overview and explanation of various RxJS operators for working with Observables, including:
- The map, filter, and scan operators for transforming streams of data. Map applies a function to each value, filter filters values, and scan applies a reducer function over time.
- Flattening operators like switchMap, concatMap, mergeMap, and exhaustMap for mapping Observables to other Observables.
- Error handling operators like catchError, retry, and retryWhen for catching and handling errors.
- Additional explanation of use cases and common mistakes for each operator discussed. The document is intended to explain these essential operators for real world reactive programming use.
The document provides an introduction to asynchronous JavaScript. It discusses callbacks and their disadvantages like callback hell. Promises are introduced as a better way to handle asynchronous code by making it easier to write and chain asynchronous operations. Async/await is described as syntactic sugar that allows asynchronous code to be written more readably in a synchronous style using await and try/catch. Key aspects like the event loop, microtask queue, and Promise methods like all and race are explained. Overall the document aims to help understand what makes asynchronous code different and newer methods like promises and async/await that improve handling asynchronous operations in JavaScript.
This document provides an overview of Angular 2 and related reactive programming concepts:
- It discusses fundamentals like reactive programming, functional reactive programming (FRP), and the observer design pattern.
- Related concepts like promises, Object.observe, and RxJS observables are explained.
- Angular 2 uses observables for forms, HTTP requests, the async pipe for change detection, and more. Pipes and change detection are also covered.
- The document compares promises and observables, and how RxJS implements observables for use in Angular 2. Bridging between different async patterns and observables is discussed.
- Questions are invited at the end regarding Angular 2 and related reactive
Asynchronous JavaScript Programming with Callbacks & PromisesHùng Nguyễn Huy
This presentation is about JavaScript Promise. Topics covered in this session are:
1. Asynchronous processing in JavaScript
2. Callbacks and Callback hell
3. Promises arrive in JavaScript!
4. Constructing a Promise
5. Promise states
6. Promises chaining and transformation
7. Error handling
8. Promise.all() and Promise.race()
NGRX provides tools for implementing Redux patterns in Angular applications. The key components are:
- The Store holds the single source of truth application state as plain JavaScript objects and uses reducers to immutable update state in response to actions.
- Actions describe state changes and are dispatched to the Store which passes them to reducers. Reducers pure functions that return new state.
- Selectors allow slices of state to be accessed.
- Additional libraries provide debugging with devtools, routing integration, side effect handling, and entity management functionality. Files can be organized by domain or feature module.
Chaque jour, de nombreux développeurs utilisent le framework Spring pour l’injection de dépendances et la gestion des transactions. Majeures, ces 2 fonctionnalités ne nécessitent pas un gros effort d’apprentissage. Pour autant, leurs mises en œuvre par le framework est complexe. Par curiosité intellectuelle, mais également afin d’éviter certains pièges et de profiter pleinement des capacités de Spring, il est intéressant de comprendre les mécanismes internes du framework qu’on utilise au quotidien : cycle de vie d’un bean, proxy, intercepteur, post-processeur, fabrique de beans, hiérarchie de contextes, portée …
Les slides de cette présentation ont pour objectif de vous les faire les introduire.
This document provides an overview of asynchronous JavaScript. It discusses how JavaScript uses a single thread and event queue. It introduces asynchronous functions and loading scripts asynchronously. It covers the requestIdleCallback function for background tasks. The document also provides an in-depth overview of promises in JavaScript for asynchronous code, including the promise lifecycle, then and catch methods, and creating promises using the Promise constructor.
The document discusses Angular 4's HTTP client module. Some key points:
1. The HTTP client uses Observables to handle asynchronous requests and responses in a reactive way. Observables allow for features like retry logic.
2. JSON responses are parsed by default, eliminating the need for manual parsing.
3. Interceptors allow adding middleware logic like authentication headers to all requests.
4. Progress events provide feedback on file upload and download progress.
Routing & Navigating Pages in Angular 2Knoldus Inc.
Routing in Angular allows directing users to different pages/components based on their navigation choices. It defines routes for pages by creating components and linking them in the routes configuration. Components can link to routes using routerLink and navigate between them in code using the Router service. Route guards prevent navigation under certain conditions. Lazy loading allows splitting the app into smaller modules to improve performance. Code is cleaned up by exporting all imports from a single index file.
This document discusses callback functions in JavaScript. A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action. Callback functions allow asynchronous code execution in JavaScript by performing tasks without blocking subsequent code from running. Common examples of callbacks include functions used in event handling and asynchronous operations like AJAX requests.
This document provides an overview of React and Redux. It introduces React as a component-based library for building user interfaces using JavaScript and JSX. Key aspects of React include its lifecycle methods, use of a virtual DOM for fast updates, and functional stateless components. Redux is introduced as a state management library that uses a single immutable store with actions and reducers. It follows the Flux architecture pattern without a dispatcher. Hands-on demos are provided for key React and Redux concepts. Resources for further learning are also listed.
Action Jackson! Effective JSON processing in Spring Boot ApplicationsJoris Kuipers
JSON processing plays an important role in nearly all applications nowadays, and Jackson is the de-facto standard library for that. Most developers are therefore familiar with using it for simple (un)marshalling purposes, but never go beyond the basics. In this session Joris will show how to effectively configure and use Jackson, focusing on Spring Boot applications. Boot provides a lot of support for configuring ObjectMappers, which you can use directly but are also used internally by the framework for e.g. handling HTTP requests/responses or message conversion. Topics will include tuning mappings, using modules, applying views and using alternative parsing options like JSON Pointer and JsonPath, all illustrated through live demos. Don’t miss out on this presentation and become an Action Jackson yourself!
Explanation of the fundamentals of Redux with additional tips and good practices. Presented in the Munich React Native Meetup, so the sample code is using React Native. Additional code: https://github.com/nacmartin/ReduxIntro
Being Functional on Reactive Streams with Spring ReactorMax Huang
The journey begins with using Java 8 introduced Optional/Stream/CompletableFuture more functional, after which Reactive Streams is introduced with a homemade implementation that is ultimately made functional to increase usability. Finally Spring Reactor (Project Reactor) is presented and used for building a device simulator periodically reporting data to device controller.
- Directives are classes that add additional behavior to elements in Angular applications. There are two types of directives - structural directives that change the DOM layout and attribute directives that change element appearance and behavior.
- Some common built-in structural directives include NgIf, NgFor, and NgSwitch. Common attribute directives include NgStyle and NgClass. Custom directives can also be created.
- Pipes are functions used in templates to accept an input value and return a transformed output value. Built-in pipes like DatePipe and CurrencyPipe format dates and numbers. Custom pipes can be made to transform values in specified ways.
This document provides an introduction to React and Redux frameworks. It discusses JavaScript components and state management with React as well as Redux for managing application state through actions, reducers, and a central store. The document also covers related topics like functional programming, smart and dumb components, and React Native platforms.
The document discusses the different life cycle hooks available in VueJS. There are 8 main lifecycle hooks: beforeCreate, created, beforeMount, mounted, beforeUpdate, updated, beforeDestroy, and destroyed. Each hook calls at a different stage of a Vue component's creation and updating, allowing developers to tap into the lifecycle at specific points to perform certain actions.
This document provides an overview of Rxjs (Reactive Extensions for JavaScript). It begins by explaining why Rxjs is useful for dealing with asynchronous code in a synchronous way and provides one paradigm for asynchronous operations. It then discusses the history of callbacks and promises for asynchronous code. The bulk of the document explains key concepts in Rxjs including Observables, Operators, error handling, testing with Schedulers, and compares Promises to Rxjs. It provides examples of many common Rxjs operators and patterns.
1) Rxjs provides a paradigm for dealing with asynchronous operations in a synchronous way using observables. Observables allow representing push-based data streams and provide operators to compose and transform these streams.
2) Operators like map, filter, and switchMap allow manipulating observable streams and their values in various ways. Common patterns include cascading asynchronous calls, parallelizing multiple requests, and retrying or error handling of streams.
3) Schedulers allow bending time and virtual clocks, enabling testing asynchronous code by controlling when asynchronous operations complete. Marble testing uses descriptive patterns to visually test observable streams and operator behavior.
Rxjs provides a paradigm for dealing with asynchronous operations in a way that resembles synchronous code. It uses Observables to represent asynchronous data streams over time that can be composed using operators. This allows handling of events, asynchronous code, and other reactive sources in a declarative way. Key points are:
- Observables represent asynchronous data streams that can be subscribed to.
- Operators allow manipulating and transforming streams through methods like map, filter, switchMap.
- Schedulers allow controlling virtual time for testing asynchronous behavior.
- Promises represent single values while Observables represent continuous streams, making Observables more powerful for reactive programming.
- Cascading asynchronous calls can be modeled elegantly using switch
Talk given at DevTeach Montreal on RxJS - The Basics & The Future.
Example repo: https://github.com/ladyleet/rxjs-test
Have questions? Find me on twitter http://twitter.com/ladyleet
RxJS Operators - Real World Use Cases (FULL VERSION)Tracy Lee
This document provides an overview and explanation of various RxJS operators for working with Observables, including:
- The map, filter, and scan operators for transforming streams of data. Map applies a function to each value, filter filters values, and scan applies a reducer function over time.
- Flattening operators like switchMap, concatMap, mergeMap, and exhaustMap for mapping Observables to other Observables.
- Error handling operators like catchError, retry, and retryWhen for catching and handling errors.
- Additional explanation of use cases and common mistakes for each operator discussed. The document is intended to explain these essential operators for real world reactive programming use.
The document provides an introduction to asynchronous JavaScript. It discusses callbacks and their disadvantages like callback hell. Promises are introduced as a better way to handle asynchronous code by making it easier to write and chain asynchronous operations. Async/await is described as syntactic sugar that allows asynchronous code to be written more readably in a synchronous style using await and try/catch. Key aspects like the event loop, microtask queue, and Promise methods like all and race are explained. Overall the document aims to help understand what makes asynchronous code different and newer methods like promises and async/await that improve handling asynchronous operations in JavaScript.
This document provides an overview of Angular 2 and related reactive programming concepts:
- It discusses fundamentals like reactive programming, functional reactive programming (FRP), and the observer design pattern.
- Related concepts like promises, Object.observe, and RxJS observables are explained.
- Angular 2 uses observables for forms, HTTP requests, the async pipe for change detection, and more. Pipes and change detection are also covered.
- The document compares promises and observables, and how RxJS implements observables for use in Angular 2. Bridging between different async patterns and observables is discussed.
- Questions are invited at the end regarding Angular 2 and related reactive
Asynchronous JavaScript Programming with Callbacks & PromisesHùng Nguyễn Huy
This presentation is about JavaScript Promise. Topics covered in this session are:
1. Asynchronous processing in JavaScript
2. Callbacks and Callback hell
3. Promises arrive in JavaScript!
4. Constructing a Promise
5. Promise states
6. Promises chaining and transformation
7. Error handling
8. Promise.all() and Promise.race()
NGRX provides tools for implementing Redux patterns in Angular applications. The key components are:
- The Store holds the single source of truth application state as plain JavaScript objects and uses reducers to immutable update state in response to actions.
- Actions describe state changes and are dispatched to the Store which passes them to reducers. Reducers pure functions that return new state.
- Selectors allow slices of state to be accessed.
- Additional libraries provide debugging with devtools, routing integration, side effect handling, and entity management functionality. Files can be organized by domain or feature module.
Chaque jour, de nombreux développeurs utilisent le framework Spring pour l’injection de dépendances et la gestion des transactions. Majeures, ces 2 fonctionnalités ne nécessitent pas un gros effort d’apprentissage. Pour autant, leurs mises en œuvre par le framework est complexe. Par curiosité intellectuelle, mais également afin d’éviter certains pièges et de profiter pleinement des capacités de Spring, il est intéressant de comprendre les mécanismes internes du framework qu’on utilise au quotidien : cycle de vie d’un bean, proxy, intercepteur, post-processeur, fabrique de beans, hiérarchie de contextes, portée …
Les slides de cette présentation ont pour objectif de vous les faire les introduire.
This document provides an overview of asynchronous JavaScript. It discusses how JavaScript uses a single thread and event queue. It introduces asynchronous functions and loading scripts asynchronously. It covers the requestIdleCallback function for background tasks. The document also provides an in-depth overview of promises in JavaScript for asynchronous code, including the promise lifecycle, then and catch methods, and creating promises using the Promise constructor.
The document discusses Angular 4's HTTP client module. Some key points:
1. The HTTP client uses Observables to handle asynchronous requests and responses in a reactive way. Observables allow for features like retry logic.
2. JSON responses are parsed by default, eliminating the need for manual parsing.
3. Interceptors allow adding middleware logic like authentication headers to all requests.
4. Progress events provide feedback on file upload and download progress.
Routing & Navigating Pages in Angular 2Knoldus Inc.
Routing in Angular allows directing users to different pages/components based on their navigation choices. It defines routes for pages by creating components and linking them in the routes configuration. Components can link to routes using routerLink and navigate between them in code using the Router service. Route guards prevent navigation under certain conditions. Lazy loading allows splitting the app into smaller modules to improve performance. Code is cleaned up by exporting all imports from a single index file.
This document discusses callback functions in JavaScript. A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action. Callback functions allow asynchronous code execution in JavaScript by performing tasks without blocking subsequent code from running. Common examples of callbacks include functions used in event handling and asynchronous operations like AJAX requests.
This document provides an overview of React and Redux. It introduces React as a component-based library for building user interfaces using JavaScript and JSX. Key aspects of React include its lifecycle methods, use of a virtual DOM for fast updates, and functional stateless components. Redux is introduced as a state management library that uses a single immutable store with actions and reducers. It follows the Flux architecture pattern without a dispatcher. Hands-on demos are provided for key React and Redux concepts. Resources for further learning are also listed.
Action Jackson! Effective JSON processing in Spring Boot ApplicationsJoris Kuipers
JSON processing plays an important role in nearly all applications nowadays, and Jackson is the de-facto standard library for that. Most developers are therefore familiar with using it for simple (un)marshalling purposes, but never go beyond the basics. In this session Joris will show how to effectively configure and use Jackson, focusing on Spring Boot applications. Boot provides a lot of support for configuring ObjectMappers, which you can use directly but are also used internally by the framework for e.g. handling HTTP requests/responses or message conversion. Topics will include tuning mappings, using modules, applying views and using alternative parsing options like JSON Pointer and JsonPath, all illustrated through live demos. Don’t miss out on this presentation and become an Action Jackson yourself!
Explanation of the fundamentals of Redux with additional tips and good practices. Presented in the Munich React Native Meetup, so the sample code is using React Native. Additional code: https://github.com/nacmartin/ReduxIntro
Being Functional on Reactive Streams with Spring ReactorMax Huang
The journey begins with using Java 8 introduced Optional/Stream/CompletableFuture more functional, after which Reactive Streams is introduced with a homemade implementation that is ultimately made functional to increase usability. Finally Spring Reactor (Project Reactor) is presented and used for building a device simulator periodically reporting data to device controller.
- Directives are classes that add additional behavior to elements in Angular applications. There are two types of directives - structural directives that change the DOM layout and attribute directives that change element appearance and behavior.
- Some common built-in structural directives include NgIf, NgFor, and NgSwitch. Common attribute directives include NgStyle and NgClass. Custom directives can also be created.
- Pipes are functions used in templates to accept an input value and return a transformed output value. Built-in pipes like DatePipe and CurrencyPipe format dates and numbers. Custom pipes can be made to transform values in specified ways.
This document provides an introduction to React and Redux frameworks. It discusses JavaScript components and state management with React as well as Redux for managing application state through actions, reducers, and a central store. The document also covers related topics like functional programming, smart and dumb components, and React Native platforms.
The document discusses the different life cycle hooks available in VueJS. There are 8 main lifecycle hooks: beforeCreate, created, beforeMount, mounted, beforeUpdate, updated, beforeDestroy, and destroyed. Each hook calls at a different stage of a Vue component's creation and updating, allowing developers to tap into the lifecycle at specific points to perform certain actions.
This document provides an overview of Rxjs (Reactive Extensions for JavaScript). It begins by explaining why Rxjs is useful for dealing with asynchronous code in a synchronous way and provides one paradigm for asynchronous operations. It then discusses the history of callbacks and promises for asynchronous code. The bulk of the document explains key concepts in Rxjs including Observables, Operators, error handling, testing with Schedulers, and compares Promises to Rxjs. It provides examples of many common Rxjs operators and patterns.
1) Rxjs provides a paradigm for dealing with asynchronous operations in a synchronous way using observables. Observables allow representing push-based data streams and provide operators to compose and transform these streams.
2) Operators like map, filter, and switchMap allow manipulating observable streams and their values in various ways. Common patterns include cascading asynchronous calls, parallelizing multiple requests, and retrying or error handling of streams.
3) Schedulers allow bending time and virtual clocks, enabling testing asynchronous code by controlling when asynchronous operations complete. Marble testing uses descriptive patterns to visually test observable streams and operator behavior.
RX (Reactive Extensions) is a library for implementing the Observer design pattern, which allows an object to publish changes to other objects through event notifications. It defines Observables, which represent asynchronous data streams, and Observers, which receive notifications for these streams. RX also includes operators that allow these streams to be transformed and combined using functional programming patterns like map and filter. This allows complex asynchronous behaviors to be easily modeled using simple declarative code.
1. Rxjs provides a better way of handling asynchronous code through observables which are streams of values over time. Observables allow for cancellable, retryable operations and easy composition of different asynchronous sources.
2. Common Rxjs operators like map, filter, and flatMap allow transforming and combining observable streams. Operators make observables quite powerful for tasks like async logic, event handling, and API requests.
3. In Angular, observables are used extensively for tasks like HTTP requests, routing, and component communication. Key aspects are using async pipes for subscriptions and unsubscribing during lifecycle hooks. Rxjs greatly simplifies many common asynchronous patterns in Angular applications.
Workshop slides from the Alt.Net Seattle 2011 workshop. Presented by Wes Dyer and Ryan Riley. Get the slides and the workshop code at http://rxworkshop.codeplex.com/
Managing application state, asynchronous events and manually updating the DOM is hard. Cycle.js is a minimal framework that combines a pure functional programming style, immutability, and state management using Observables and Virtual DOM rendering. In this presentation we take a mild introduction to why that's interesting.
Web development is hard. Managing asynchronous events and updating the dom directly quickly becomes a mess. Cycle.js uses streams and pure functions to help. You can find the presentation video in https://youtu.be/1yXgFFVVJDw
Tech Talk #4 : RxJava and Using RxJava in MVP - Dương Văn TớiNexus FrontierTech
RxJava is a library for composing asynchronous and event-based programs using observable sequences. It allows processing streams of data and events asynchronously without blocking threads. Some key features include:
- Creating Observables from various sources like arrays, callbacks, or network requests
- Combining multiple Observables using operators like map, filter, concatMap
- Scheduling Observables to run on different threads for IO, computation, or the main thread
- Subscribing to Observables using Subscriber, Observer, or other callback methods
When using RxJava with MVP, Observables can be used to asynchronously load and transform data from the model to be presented by the view. Operators allow processing streams of data before
This document provides an overview of ReactiveX (Rx), which is an API for asynchronous programming using observable streams. It discusses key Rx concepts like Observables, which represent sets of values over time that can be subscribed to; Operators, which allow transforming, combining, and manipulating observable streams; and Subjects, which act as both Observable and Observer and are useful for multicasting streams. The document provides examples of using Rx in autocomplete applications and discusses Schedulers, which define the execution context for asynchronous operations in Rx. Overall, the document serves as a high-level introduction to the reactive programming paradigm and Rx library.
RxJava is an open source library for reactive programming that allows processing asynchronous streams of data. It provides operators to filter, transform, and combine Observables in a lazy manner. Observables represent asynchronous data streams that can be subscribed to receive push-based event notifications. Services return Observables to make their APIs asynchronous and reactive.
The document discusses reactive programming concepts using RxJava. It introduces observables and observers, where observables push asynchronous events to observers via subscriptions. It explains how to create observables that return asynchronous values, and how operators like map, filter, and flatMap can transform and combine observable streams. Key lessons are that performance depends on operator implementations, debugging subscriptions can be difficult, and IDE support for reactive code is still maturing.
Building Scalable Stateless Applications with RxJavaRick Warren
RxJava is a lightweight open-source library, originally from Netflix, that makes it easy to compose asynchronous data sources and operations. This presentation is a high-level intro to this library and how it can fit into your application.
RxJS - The Reactive extensions for JavaScriptViliam Elischer
RxJS is a library for composing asynchronous and event-based programs using observable sequences and functional style operators. It provides developers with Observables to represent asynchronous data streams, operators to query those streams, and Schedulers to parameterize concurrency. Some key operators include map to project values, filter to select values, reduce to aggregate values, and flatMap to flatten nested observables. RxJS supports both hot and cold observables, and is used for tasks like DOM event handling, API communication, and state management in applications.
This document summarizes an introductory presentation on RxJava. It begins with definitions of reactive programming and RxJava, noting that RxJava allows for composing asynchronous and event-based programs using observable sequences. It then discusses some common problems with concurrency in Android and how RxJava provides solutions through concepts like Observables, operators, and schedulers. It provides examples of using RxJava for common tasks like network requests and timers. It concludes with some common mistakes to avoid like improper use of schedulers and failing to unsubscribe.
RxJava is a library for composing asynchronous and event-based programs using observable sequences. It allows avoiding callback hell and makes it easy to compose and transform asynchronous processes through combining, filtering, etc. RxJava uses Observables to represent asynchronous data streams and allows subscribing to those streams using Observers. It supports asynchronous operations through Schedulers and can integrate with libraries like Retrofit to handle asynchronous network requests in a reactive way. Learning the RxJava concepts and operators takes some time but it provides many benefits for managing asynchronous code in a declarative way.
This document provides an introduction and overview of the NSubstitute mocking framework. It begins with an agenda that covers test doubles, test driven development, and the key features of NSubstitute. The document then discusses creating substitutes, setting return values, argument matchers, checking received calls, raising events, auto and recursive mocking, and advantages over alternatives like Moq and Rhino Mocks. The goal of NSubstitute is to provide a simple and succinct syntax for writing clearer tests.
Presented at YOW! Connected 2015 (Melbourne) by Jeames Bone & Mark Corbyn:
"There are many great resources for getting started with Functional Reactive Programming and ReactiveCocoa, but what’s the next step? ReactiveCocoa is not just a nice wrapper for KVO, Signals can be used to model many common problems in Cocoa including managing the state of your UI, notifications and even business logic. Adopting ReactiveCocoa can make for more modular, self-documenting code — while still integrating easily with other APIs and your existing code. We would like to share with you some interesting, practical examples where we’ve used ReactiveCocoa to solve problems in our app. Our goal is to inspire you to consider how ReactiveCocoa can be applied in your own apps."
RxJS Operators - Real World Use Cases - AngularMixTracy Lee
If you want to learn about the most important operators you need to know, check out this deck.
I touch on ~20 most common operators that you need in your arsenal, when you should be using them, and when you should not.
Vadym Khondar is a senior software engineer with 8 years of experience, including 2.5 years at EPAM. He leads a development team that works on web and JavaScript projects. The document discusses reactive programming, including its benefits of responsiveness, resilience, and other qualities. Examples demonstrate using streams, behaviors, and other reactive concepts to write more declarative and asynchronous code.
This document provides an overview of Azure SignalR, which enables real-time functionality over HTTP without polling. It discusses how Azure SignalR works by establishing a connection between clients and the Azure SignalR service to send and receive messages. The document also covers when Azure SignalR should be used, the runtimes it supports, how to set up a serverless architecture with Azure Functions, and how billing works based on outbound messages.
The document provides instructions for building a basic space shooter game using JavaScript and canvas. It demonstrates how to load assets like images, handle input events from keyboard keys to control player movement, create enemy objects that move across the screen, detect collisions between lasers and enemies, and add game states to track lives and score. The game loop redraws the game objects on an interval to animate their movement. Event handling is implemented through an event emitter to avoid messy code. The final sections provide a demo of the moving game elements and lasers firing, along with tips for continuing to learn game development.
Programming a game involves several phases: setup, running the game, listening for user input and enemy movement, handling world events, and tracking state changes. It is like following a recipe by defining variables for data like eggs and sugar, and functions for actions like whisking and baking. JavaScript and Canvas allow drawing on a web page, like loading an image for a player ship and painting a background. The next step is adding movement to the space game.
This document discusses elements that make games engaging as well as mechanics that can be used to design games. A good game is amusing, fun, and challenging for the player. It provides a goal for the player to work towards, such as winning a race or collecting points, and introduces opponents, whether computer-controlled enemies or other human players. Common game mechanics include actions the player can take, characters like avatars and enemies, an interactive environment, and challenges like avoiding enemies or finding hidden areas. Examples discussed are classic games like Super Mario 3, Galaga, and Quake to illustrate different mechanics like movement, shooting, jumping, and collecting items or defeating bosses. The document encourages designing new games using a tool like MakeCode Arc
The document discusses infrastructure as code using ARM templates on Azure. ARM templates allow infrastructure to be defined in code and treated like application code in version control. Key points covered include:
- ARM templates are JSON files that define Azure resources and deployment parameters
- Templates support parameters, variables, functions and outputs to define flexible and repeatable deployments
- Common elements like resources, properties, and tags can be authored in templates
- Templates are deployed via tools like Powershell or Azure CLI to create the defined infrastructure
Svelte is a compiler that optimizes code by avoiding unnecessary updates. It allows building standalone components without dependencies on frameworks. Svelte compiles code to plain JavaScript that can run anywhere. Key features include bindings that sync state between components and templates, reusable components, and directives like if/else and each that control the template.
This document discusses open-source software (OSS) and provides examples of commonly used OSS tools and frameworks. It defines OSS as software with source code released under an open-source license allowing users to study, change and distribute the software. Examples of widely used OSS projects mentioned include RxJS, NestJS, Ngrx, AngularFire, Nx, and Ionic. The document also discusses how developers can contribute to OSS projects through code contributions, funding, or other support and the challenges faced by OSS maintainers.
Schematics allow developers to define rules that transform a file system tree representation. They provide a workflow tool for scaffolding new components and services as well as updating existing code. The Angular CLI uses schematics under the hood to provide its functionality. Developers can build their own schematics to customize workflows by defining rules that apply transformations to a tree representation of files.
This document provides an overview of design thinking. It discusses how design thinking is an iterative process that involves empathizing with users, defining problems from the user's perspective, ideating solutions, prototyping ideas, and testing prototypes. Rather than taking problems at face value, design thinking challenges assumptions to reframe problems in a human-centered way. It encourages exploring unknown aspects of problems and generating alternative solutions. The document provides examples of how well-known problems could be viewed more broadly and solved innovatively using a design thinking approach focused on user needs rather than predefined solutions.
This document discusses strategies for overcoming imposter syndrome as a developer. It recommends practicing coding through challenges, open source contributions, and side projects to build unconscious competence. Communication skills like writing and public speaking can help clarify thinking. Changing one's mindset to believe in their ability to learn and solve problems is important. Ultimately, developers must choose to spend hours practicing and deciding how great they want to become.
Vue and Vuex allow you to build interactive web applications. The document discusses Vue basics like creating components, passing data between components using props and events, and routing between multiple pages. It also covers more advanced topics such as validating component inputs, watching for data changes, and using route parameters and query strings.
This document provides an overview of using Kendo UI components with Angular. It discusses why one might choose to use Kendo UI, describes some of the main component groups like buttons, charts, dropdowns, grids, layout, popup, dialog, date inputs and inputs. It also covers how to install and configure themes, and how to import, display and handle events of the different components. The document is intended as a guide for developers looking to get started with building applications using Kendo UI and Angular.
This document discusses the history of asynchronous programming and how reactive programming with RxJS addresses limitations of previous approaches. It covers callback hell with nested callbacks, promises, and async/await. RxJS introduces Observables that allow streaming and combining of asynchronous data over time. The document demonstrates building basic Observable and Observer classes as well as an operator. Reactive programming with RxJS makes asynchronous code more readable and addresses issues like cancellation and error handling.
This document provides an overview of building NativeScript applications with Angular. It covers setting up a NativeScript project with Angular, using components and bindings, routing, forms, HTTP requests, and testing. While there are some minor differences from web Angular, NativeScript aims to embrace the Angular framework and allow building truly native mobile apps using Angular concepts.
Template forms allow creating forms directly in the template using directives like ngModel. Reactive forms use FormBuilder to build forms programmatically and attach validators and value changes. Both approaches allow collecting and validating user input, and associating forms with models. Forms are a key part of many applications for user input and data collection.
This document provides an introduction to RxJS, a library for reactive programming using Observables. It discusses some of the key concepts in RxJS including Observables, operators, and recipes. Observables can be created from events, promises, arrays and other sources. Operators allow chaining transformations on Observables like map, filter, switchMap. RxJS is useful for complex asynchronous flows and is easier to test than promises using marble testing. Overall, RxJS enables rich composition of asynchronous code and cancellation of Observables.
This document provides an overview of React and Redux concepts including:
- React basics like components, props, state, and lifecycle methods
- Flux architecture and how data flows through actions, dispatcher, and stores
- Redux as an alternative to Flux that uses a single store updated by reducers in response to actions
- Additional React topics like JSX, propTypes, and using React with ES6 classes are also covered.
- Angular modules help organize an application into blocks of related functionality. Modules declare components, directives, pipes and services that belong to that module.
- There are different types of modules like root modules, feature modules, and shared modules. The root module launches the app. Feature modules extend functionality. Shared modules contain reusable constructs.
- Modules can import and export specific constructs to make them available to other modules. Services declared in a module are singletons app-wide unless the module is lazy loaded. Core modules contain global services imported by the root module only.
Programming Foundation Models with DSPy - Meetup SlidesZilliz
Prompting language models is hard, while programming language models is easy. In this talk, I will discuss the state-of-the-art framework DSPy for programming foundation models with its powerful optimizers and runtime constraint system.
Unlocking Productivity: Leveraging the Potential of Copilot in Microsoft 365, a presentation by Christoforos Vlachos, Senior Solutions Manager – Modern Workplace, Uni Systems
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
Have you ever been confused by the myriad of choices offered by AWS for hosting a website or an API?
Lambda, Elastic Beanstalk, Lightsail, Amplify, S3 (and more!) can each host websites + APIs. But which one should we choose?
Which one is cheapest? Which one is fastest? Which one will scale to meet our needs?
Join me in this session as we dive into each AWS hosting service to determine which one is best for your scenario and explain why!
In his public lecture, Christian Timmerer provides insights into the fascinating history of video streaming, starting from its humble beginnings before YouTube to the groundbreaking technologies that now dominate platforms like Netflix and ORF ON. Timmerer also presents provocative contributions of his own that have significantly influenced the industry. He concludes by looking at future challenges and invites the audience to join in a discussion.
For the full video of this presentation, please visit: https://www.edge-ai-vision.com/2024/06/building-and-scaling-ai-applications-with-the-nx-ai-manager-a-presentation-from-network-optix/
Robin van Emden, Senior Director of Data Science at Network Optix, presents the “Building and Scaling AI Applications with the Nx AI Manager,” tutorial at the May 2024 Embedded Vision Summit.
In this presentation, van Emden covers the basics of scaling edge AI solutions using the Nx tool kit. He emphasizes the process of developing AI models and deploying them globally. He also showcases the conversion of AI models and the creation of effective edge AI pipelines, with a focus on pre-processing, model conversion, selecting the appropriate inference engine for the target hardware and post-processing.
van Emden shows how Nx can simplify the developer’s life and facilitate a rapid transition from concept to production-ready applications.He provides valuable insights into developing scalable and efficient edge AI solutions, with a strong focus on practical implementation.
Best 20 SEO Techniques To Improve Website Visibility In SERPPixlogix Infotech
Boost your website's visibility with proven SEO techniques! Our latest blog dives into essential strategies to enhance your online presence, increase traffic, and rank higher on search engines. From keyword optimization to quality content creation, learn how to make your site stand out in the crowded digital landscape. Discover actionable tips and expert insights to elevate your SEO game.
Full-RAG: A modern architecture for hyper-personalizationZilliz
Mike Del Balso, CEO & Co-Founder at Tecton, presents "Full RAG," a novel approach to AI recommendation systems, aiming to push beyond the limitations of traditional models through a deep integration of contextual insights and real-time data, leveraging the Retrieval-Augmented Generation architecture. This talk will outline Full RAG's potential to significantly enhance personalization, address engineering challenges such as data management and model training, and introduce data enrichment with reranking as a key solution. Attendees will gain crucial insights into the importance of hyperpersonalization in AI, the capabilities of Full RAG for advanced personalization, and strategies for managing complex data integrations for deploying cutting-edge AI solutions.
CAKE: Sharing Slices of Confidential Data on BlockchainClaudio Di Ciccio
Presented at the CAiSE 2024 Forum, Intelligent Information Systems, June 6th, Limassol, Cyprus.
Synopsis: Cooperative information systems typically involve various entities in a collaborative process within a distributed environment. Blockchain technology offers a mechanism for automating such processes, even when only partial trust exists among participants. The data stored on the blockchain is replicated across all nodes in the network, ensuring accessibility to all participants. While this aspect facilitates traceability, integrity, and persistence, it poses challenges for adopting public blockchains in enterprise settings due to confidentiality issues. In this paper, we present a software tool named Control Access via Key Encryption (CAKE), designed to ensure data confidentiality in scenarios involving public blockchains. After outlining its core components and functionalities, we showcase the application of CAKE in the context of a real-world cyber-security project within the logistics domain.
Paper: https://doi.org/10.1007/978-3-031-61000-4_16
Monitoring and Managing Anomaly Detection on OpenShift.pdfTosin Akinosho
Monitoring and Managing Anomaly Detection on OpenShift
Overview
Dive into the world of anomaly detection on edge devices with our comprehensive hands-on tutorial. This SlideShare presentation will guide you through the entire process, from data collection and model training to edge deployment and real-time monitoring. Perfect for those looking to implement robust anomaly detection systems on resource-constrained IoT/edge devices.
Key Topics Covered
1. Introduction to Anomaly Detection
- Understand the fundamentals of anomaly detection and its importance in identifying unusual behavior or failures in systems.
2. Understanding Edge (IoT)
- Learn about edge computing and IoT, and how they enable real-time data processing and decision-making at the source.
3. What is ArgoCD?
- Discover ArgoCD, a declarative, GitOps continuous delivery tool for Kubernetes, and its role in deploying applications on edge devices.
4. Deployment Using ArgoCD for Edge Devices
- Step-by-step guide on deploying anomaly detection models on edge devices using ArgoCD.
5. Introduction to Apache Kafka and S3
- Explore Apache Kafka for real-time data streaming and Amazon S3 for scalable storage solutions.
6. Viewing Kafka Messages in the Data Lake
- Learn how to view and analyze Kafka messages stored in a data lake for better insights.
7. What is Prometheus?
- Get to know Prometheus, an open-source monitoring and alerting toolkit, and its application in monitoring edge devices.
8. Monitoring Application Metrics with Prometheus
- Detailed instructions on setting up Prometheus to monitor the performance and health of your anomaly detection system.
9. What is Camel K?
- Introduction to Camel K, a lightweight integration framework built on Apache Camel, designed for Kubernetes.
10. Configuring Camel K Integrations for Data Pipelines
- Learn how to configure Camel K for seamless data pipeline integrations in your anomaly detection workflow.
11. What is a Jupyter Notebook?
- Overview of Jupyter Notebooks, an open-source web application for creating and sharing documents with live code, equations, visualizations, and narrative text.
12. Jupyter Notebooks with Code Examples
- Hands-on examples and code snippets in Jupyter Notebooks to help you implement and test anomaly detection models.
Infrastructure Challenges in Scaling RAG with Custom AI modelsZilliz
Building Retrieval-Augmented Generation (RAG) systems with open-source and custom AI models is a complex task. This talk explores the challenges in productionizing RAG systems, including retrieval performance, response synthesis, and evaluation. We’ll discuss how to leverage open-source models like text embeddings, language models, and custom fine-tuned models to enhance RAG performance. Additionally, we’ll cover how BentoML can help orchestrate and scale these AI components efficiently, ensuring seamless deployment and management of RAG systems in the cloud.
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUpanagenda
Webinar Recording: https://www.panagenda.com/webinars/hcl-notes-und-domino-lizenzkostenreduzierung-in-der-welt-von-dlau/
DLAU und die Lizenzen nach dem CCB- und CCX-Modell sind für viele in der HCL-Community seit letztem Jahr ein heißes Thema. Als Notes- oder Domino-Kunde haben Sie vielleicht mit unerwartet hohen Benutzerzahlen und Lizenzgebühren zu kämpfen. Sie fragen sich vielleicht, wie diese neue Art der Lizenzierung funktioniert und welchen Nutzen sie Ihnen bringt. Vor allem wollen Sie sicherlich Ihr Budget einhalten und Kosten sparen, wo immer möglich. Das verstehen wir und wir möchten Ihnen dabei helfen!
Wir erklären Ihnen, wie Sie häufige Konfigurationsprobleme lösen können, die dazu führen können, dass mehr Benutzer gezählt werden als nötig, und wie Sie überflüssige oder ungenutzte Konten identifizieren und entfernen können, um Geld zu sparen. Es gibt auch einige Ansätze, die zu unnötigen Ausgaben führen können, z. B. wenn ein Personendokument anstelle eines Mail-Ins für geteilte Mailboxen verwendet wird. Wir zeigen Ihnen solche Fälle und deren Lösungen. Und natürlich erklären wir Ihnen das neue Lizenzmodell.
Nehmen Sie an diesem Webinar teil, bei dem HCL-Ambassador Marc Thomas und Gastredner Franz Walder Ihnen diese neue Welt näherbringen. Es vermittelt Ihnen die Tools und das Know-how, um den Überblick zu bewahren. Sie werden in der Lage sein, Ihre Kosten durch eine optimierte Domino-Konfiguration zu reduzieren und auch in Zukunft gering zu halten.
Diese Themen werden behandelt
- Reduzierung der Lizenzkosten durch Auffinden und Beheben von Fehlkonfigurationen und überflüssigen Konten
- Wie funktionieren CCB- und CCX-Lizenzen wirklich?
- Verstehen des DLAU-Tools und wie man es am besten nutzt
- Tipps für häufige Problembereiche, wie z. B. Team-Postfächer, Funktions-/Testbenutzer usw.
- Praxisbeispiele und Best Practices zum sofortigen Umsetzen
OpenID AuthZEN Interop Read Out - AuthorizationDavid Brossard
During Identiverse 2024 and EIC 2024, members of the OpenID AuthZEN WG got together and demoed their authorization endpoints conforming to the AuthZEN API
“An Outlook of the Ongoing and Future Relationship between Blockchain Technologies and Process-aware Information Systems.” Invited talk at the joint workshop on Blockchain for Information Systems (BC4IS) and Blockchain for Trusted Data Sharing (B4TDS), co-located with with the 36th International Conference on Advanced Information Systems Engineering (CAiSE), 3 June 2024, Limassol, Cyprus.
Taking AI to the Next Level in Manufacturing.pdfssuserfac0301
Read Taking AI to the Next Level in Manufacturing to gain insights on AI adoption in the manufacturing industry, such as:
1. How quickly AI is being implemented in manufacturing.
2. Which barriers stand in the way of AI adoption.
3. How data quality and governance form the backbone of AI.
4. Organizational processes and structures that may inhibit effective AI adoption.
6. Ideas and approaches to help build your organization's AI strategy.
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
How to Get CNIC Information System with Paksim Ga.pptxdanishmna97
Pakdata Cf is a groundbreaking system designed to streamline and facilitate access to CNIC information. This innovative platform leverages advanced technology to provide users with efficient and secure access to their CNIC details.
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Speck&Tech
ABSTRACT: A prima vista, un mattoncino Lego e la backdoor XZ potrebbero avere in comune il fatto di essere entrambi blocchi di costruzione, o dipendenze di progetti creativi e software. La realtà è che un mattoncino Lego e il caso della backdoor XZ hanno molto di più di tutto ciò in comune.
Partecipate alla presentazione per immergervi in una storia di interoperabilità, standard e formati aperti, per poi discutere del ruolo importante che i contributori hanno in una comunità open source sostenibile.
BIO: Sostenitrice del software libero e dei formati standard e aperti. È stata un membro attivo dei progetti Fedora e openSUSE e ha co-fondato l'Associazione LibreItalia dove è stata coinvolta in diversi eventi, migrazioni e formazione relativi a LibreOffice. In precedenza ha lavorato a migrazioni e corsi di formazione su LibreOffice per diverse amministrazioni pubbliche e privati. Da gennaio 2020 lavora in SUSE come Software Release Engineer per Uyuni e SUSE Manager e quando non segue la sua passione per i computer e per Geeko coltiva la sua curiosità per l'astronomia (da cui deriva il suo nickname deneb_alpha).
3. What is reactive programming?
Is a programming paradigm
Focuses on propagating changes
without us having to explicitly specify how the propagation happens
State what our code should to
without having to code every line
5. Functional over imperative
var list = [ 1,2,3,4,5 ];
var newList = list.map( function(value) {
return value + 1;
})
Produces a new list
list NOT mutated/changed
but projected
Functional
Imperative
var list = [ 1,2,3,4,5 ];
list.forEach( function(value) {
value += 1;
})
X number invocation changes state
6. Reactive programming
Async data streams
Turn
click events
user inputs
data from server
callbacks into a stream
One paradigm/ api to rule them all
7. Observable pattern
Iterative pattern
Observer
Observable, observable sequence
= Rx pattern
Emits its values in order, like an iterator,
BUT pushes values as they become available
Has access to a producer in an observable pattern
Push-based behaviour,
don’t call us, we’ll call you
Consumer of an observable
Like listener in observable pattern
Doesn’t start streaming unless it has at least
one Observer subscribed to it
9. Promise vs Array vs
Observable
list
.map( x = > x.prop )
.filter( x => x > 2 )
.take( 2 )
list
.map( x = > x.prop )
.filter( x => x > 2 )
.take( 2 )
.subscribe(
x => console.log(x),
)
Array Observable
Promise
service.get()
.then( x => console.log(x) )
)
Array like,
handles async
but can also
- Cancelled
- Retried
10. Observable vs Observable pattern
function Producer(){
this.listeners = [];
}
Producer.prototype.add = function(listener){
this.listeners.push( listener );
}
Producer.prototype.notify = function(message){
this.listeners.forEach( function(listener){
listener.update( message );
})
}
var stream = new Rx.Observable(function(observer) {
observer.onNext('message');
})
stream.subscribe( function(val){
console.log( val );
})
11. Observable is usually NOT the producer,
it has access to one though
var stream = new Rx.Observable(function(observer){
var producer = new Producer();
producer.nextValue( function(val){
observer.onNext( val );
})
})
function Producer(){
}
Producer.prototype.nextValue = function(cb){
setTimeout(function(){
cb( 1 );
},2000);
}
Producer created internally =
“cold observable”
Also responsible for emitting value
to observer
21. Cold observable = producer is not shared
var cold = new Observable((observer) => {
var producer = new Producer();
// have observer listen to producer here
});
var producer = new Producer();
var hot = new Observable((observer) => {
// have observer listen to producer here
});
A producer is the source of values for your observable.
Operators
multicasting
22. Going from hot to cold
Operators
multicasting
var stream = Rx.Observable.interval(1000);
stream.subscribe(function(val){
console.log('Subscriber 1', val);
});
stream.subscribe(function(val){
console.log('Subscriber 2', val);
});
By definition cold,
as both subscriber start from 0,1 ..
NOT shared
Subscriber 1 ,0
Subscriber 2 ,0
Starts on same number
25. Observable
common operators
var stream = Rx.Observable.of(1,2,3,4,5);
stream.map((val) => {
return val + 1;
})
.filter((val) => {
return val % 3 === 0;
})
Investigates every value
28. Operators
utility
var stream = Rx.Observable.of(1,2,3,4,5);
var subscription = stream
.do(function(val){
console.log('Current val', val);
})
.filter(function(val){
return val % 2 === 0;
});
subscription.subscribe(function(val){
console.log('Val',val);
})
Echos every value
without changing it,
used for logging
Do
29. Operators
utility
toPromise Used to create a promise
from an observable
stream
.filter(function(val){
return val % 2 === 0;
})
.toPromise()
.then( function(val){
console.log('Promise', val);
}) 4
var stream = Rx.Observable.of(1,2,3,4,5);
Only latest value that fulfils filter is returned
30. Operators
utility
let
stream
.let( observable =>
observable
.filter(function(x){
return x % 2 > 0;
}))
.take(2)
.subscribe(function(val){
console.log('let', val);
})
Let’s us operate on the
observable.
We don’t need to return
what we do
like with a normal operator
stream
.filter(function(val){
return val % 2 === 0;
})
var stream = Rx.Observable.of(1,2,3,4,5);
31. Operators
utilityDelay,
the whole sequence
stream
.delay(1000)
.subscribe( (val) => {
var newTime = new Date().getTime();
console.log('Delayed', val + " " + (newTime - time));
})
Rx.Observable.merge(
Rx.Observable.of('Marco').delay(1000),
Rx.Observable.of('Polo').delay(2000)
).subscribe((val) => {
var newTime = new Date().getTime();
console.log('Merged Delay', val + " " + (newTime - time));
})
….. 1 second
1
2
3
….. 1 second
Marco
….. 2 second
Polo
33. Operators
combination
concat
merge
var concat = Rx.Observable.concat(
stream,
stream2
);
var stream = Rx.Observable.fromArray([1,2,3,4]);
var stream2 = Rx.Observable.fromArray([5,6,7,8]);
1, 2, 3, 4, 5, 6, 7 ,8
var merge = Rx.Observable.merge(
stream,
stream2
);
1, 5, 2, 6, 3, 7, 4 ,8
first stream emits all values
then remaining value
streams take turn
There is difference so choose wisely
34. Operators
combination
var stream = Rx.Observable.fromArray([1,2,3,4]);
var stream2 = Rx.Observable.fromArray([5,6,7,8]);
var combineLatest = Rx.Observable.combineLatest(
stream,
stream2
);
combineLatest.subscribe( function(val) {
console.log( 'combine ', val )
})
combineLatest
[1,5], [2,6], [3,7], [4,8]
42. Operators
transformation
var numbers = Rx.Observable.interval(1000);
var bufferBy = Rx.Observable.fromEvent(document,'click');
var buffered = numbers.buffer( bufferBy );
buffered.subscribe(function(values){
console.log('Buffered',values);
});
[1,2]
[3,4,5,6,7]
etc…
Numbers are generated to a buffer
until condition is met,
then the buffer content is emitted
Buffer
43. Operators
transformation
var bufferTime = numbers.bufferTime(2000);
bufferTime.subscribe(function(values){
console.log("Buffer time",values);
})
var numbers = Rx.Observable.interval(1000);
Waits x miliseconds and then emits buffer
BufferTime
44. var expand = Rx.Observable
.of(2)
.expand(function(val){
return Rx.Observable.of(1 + val);
})
.take(3);
expand.subscribe(function(val){
console.log('Expand',val);
})
Operators
transformationExpand
Recursively call provided callback
x times
45. Operators
transformation
Scan
var scanning = Rx.Observable
.of({ prop : 'a'}, { prop2 : 'b'})
.scan((acc, curr) => Object.assign({}, acc, curr), {});
scanning.subscribe( function(val){
console.log( val );
});
Add accumulated
and current
var sum = Rx.Observable
.of(1,2,3)
.do(function(){
console.log('Create side effects');
})
.scan(function(acc,curr) {
console.log('Curr', curr);
return acc + curr;
{ prop : ‘a’ }
{ prop : ‘a’, prop2 : ‘b’ }
1
3
6
46. Operators
transformation
Switch map,
complete something based on a condition
breakCondition = Rx.Observable.fromEvent(document,'click');
breakCondition.switchMap( function(val){
return Rx.Observable.interval(3000).mapTo('Do this if nothing breaks me');
})
breakCondition.subscribe( function(val){
console.log('Switch map', val);
})
Intended action is completed/restarted
by ‘breakCondition’
47. var sourceTiming = timingBreakCondition.switchMap( function(val){
return Rx.Observable.interval(1000).map(function(val){
return 'Emitting' + (val + 1);
})
})
sourceTiming.subscribe(function(val){
console.log('Switch map timer', val);
})
Operators
transformation
Emits 1,2 until it is restarted by
outer timer
Switch map
var timingBreakCondition = Rx.Observable.interval(3000);
48. Operators
transformation
var breakCondition = Rx.Observable.fromEvent(document,'click');
var source = breakCondition.switchMap( function(val){
return Rx.Observable.interval(3000).take(1)
.flatMap(function(){
return Rx.DOM.getJSON( 'data3.json' );
});
})
source.subscribe( function(val){
console.log('Switch map', val);
})
Get data every 3 second unless a ‘click’ happens
Switch map
Same example but do something useful like fetch data
49. flatMap
Takes an array of observables and
merges these into one meta stream
var stream= Rx.Observable
.fromArray([1,2,3,4])
.take(2)
.flatMap(function(val){
return Rx.Observable.interval(500).map(function(){
return val;
});
});
stream.subscribe(function(val){
console.log( val );
});
Creates observables
Will emit 1,2 in eternity
Operators
transformation
50. flatMap + json
var source = Rx.DOM.getJSON( 'data2.json' )
.flatMap( function(data) {
return Rx.Observable.fromArray( data ).map(function(row){
return row.props.name;
});
} );
source.subscribe( function(data){
console.log( data );
}) Takes array response
and emits it row by row
.flatMap( function(data) {
return Rx.Observable.fromArray( data ).pluck('props','name');
} );
.flatMap(Rx.Observable.fromArray).pluck('props','name')
Operators
transformation
1
2
3
51. Excellent to use when coming from
one stream to another
Operators
transformation
flatMap - example 2
flatmapExample = Rx.Observable.fromEvent(input,'keyup')
.map( function(ev){
return ev.target.value;
})
.filter(function(text){
return text.length >=3;
})
.distinctUntilChanged()
.flatMap( function(val){
return Rx.DOM.getJSON( 'data3.json' );
})
flatmapExample.subscribe( function(result){
console.log('Flatmap', result);
})
Transform event to char
Wait until we have 3 chars
Only perform search if this ‘search’ is unique
55. Error handling improved catch
var errStream = Rx.Observable.throw('Error');
var stream = Rx.Observable.create(function(observer){
observer.onNext(1);
})
var merged = Rx.Observable
.merge( errStream, stream )
.catch(function(err){
return Rx.Observable.of(err);
});
merged.subscribe( function(val){
console.log('Val', val);
}, function(err){
console.log('Err', err);
}, function(){
console.log('completed');
})
Captured here but sequence
interrupted,
completed IS reached
stream not processed though
can we improve it?
56. Wrap error stream before merging with other streams
so we don’t kill other valid streams
Error handling
57. Error handling
ignoring
We need to handle the erroring stream better
From
var errStream = Rx.Observable
.throw('AAA thump..')
To
var errStream = Rx.Observable
.throw('AAA thump..')
.catch(function(err){
return Rx.Observable.of(err);
});
This will emit all values and the wrapped error
58. Process all values and errors by wrapping the errors,
everything gets processed
Error handling
60. Set a policy for error handling of streams when merging so
successful stream survive
Error handling
61. Error - ignoring
other scenario
You have several sources and two terminates
You want the other normal source to work
var errStream = Rx.Observable
.throw('AAA thump..');
var errStreamWithFlattenedData = Rx.Observable
.interval(500)
.take(3)
.flatMap( function(val){
if( val === 1 ) {
return Rx.Observable.throw('crashing');
}
else {
return Rx.Observable.return(val);
}
})
var normalStream = Rx.Observable.return('anything');
var handledErrorStream =
Rx.Observable.onErrorResumeNext( errStream,
normalStream, errStreamWithFlattenedData );
handledErrorStream.subscribe(function(err){
console.log('error stream ignored', err);
},
function(err){
console.log("error stream ignored, error",err);
}, function(){
console.log("completion of error stream ignored");
})
Dies midstream though,
you probably want to handle it fully
62. Error - Retrying
var stream = Rx.DOM.get('/products.json').retry(5);
stream.subscribe((val) => {
console.log('Data', val);
}, err => console.log(err));
Good thing with a shaky connection
5 attemps are made until it comes as an error
64. Subject
example
var subject = new Rx.Subject();
subject.subscribe((val) => {
console.log( 'Produced by subject', val );
});
subject.onNext(1);
subject.onCompleted();
function Producer(){
this.i = 0;
}
Producer.prototype.nextValue = function(){
return i++;
}
var observable = new Rx.Observable((observer) => {
var producer = new Producer();
observer.onNext(producer.nextValue());
observer.onCompleted();
});
observable.subscribe( (val) => {
console.log('Normal observable')
});
Bold is usually an operator like
.of() or .interval()
Acts like a observer
Acts like an observable
65. Subject
var subject = new Rx.Subject();
var source = Rx.Observable.interval(500);
source.subscribe(subject);
subject.subscribe(
(val) => {
console.log('Sub', val);
},
(err) => console.log(err),
() => console.log('completed')
);
setTimeout(function() {
subject.onCompleted();
}, 3000);
Pass subject as an observer
Receives all the values pushed out by the source
Able to stop receiving values
66. Subject
proxy one stream and add to it
var subject = new Rx.Subject();
var source = Rx.Observable.interval(500).take(3);
source.subscribe( subject );
subject.subscribe((val) => {
console.log('Subject', val);
});
subject.onNext('Mess1');
subject.onNext('Mess2');
setTimeout(function() {
subject.onCompleted();
}, 1600);
Listens to all values from source
Add to stream
Order important
67. Subject
different types
AsyncSubject
Returns a single value IF it completes
Cached forever
Good for ajax requests
BehaviorSubject
Receives last emitted value
and then all subsequent ones
Good for a placeholder
then real data to replace it scenario
68. var subject = Rx.ReplaySubject();
subject.onNext(1);
subject.subscribe((val) = > {
console.log('Replay', val);
})
subject.onNext(2);
subject.onNext(3);
var subject = Rx.Subject();
subject.onNext(1);
subject.subscribe((val) = > {
console.log('Replay', val);
})
subject.onNext(2);
subject.onNext(3);
Subject
different types
Normal subject, everything before
subscribe is lost
Replay subject, nothing is lost
70. Schedulers
Is an operator async or sync?
Give you fine grained control over how an observable emits notifications
Does it block the event loop?
Can I control how notifications are emitted?
71. Scheduler
bend it like beckham
Switch from Rx.Scheduler.currentThread to Rx.Scheduler.default
var stream = Rx.Observable.of(1,2,3,4,5);
var now = new Date().getTime();
stream.subscribe(
(val) => {
console.log('Current thread')
},
err => {},
() => {
var done = new Date().getTime();
console.log( (done - now) + "ms" );
})
5ms
ar defaultStream = Rx.Observable.from([1,2,3,4,5],null,null,
Rx.Scheduler.default);
defaultStream.subscribe((val) => {
console.log('Default', val);
},
err => {},
() => {
var done = Date.now();
console.log( "default " + (done - now) + "ms" );
})
console.log('default');
This happens first
default is async 143ms !!
72. Scheduler
Use the right scheduler for the right things
Constant Time Operations => Rx.Scheduler.immediate
Tail Recursive Operations =>Rx.Scheduler.immediate
Iteration Operations => Rx.Scheduler.currentThread
Time-based Operations => Rx.Scheduler.default
Asynchronous Conversions => Rx.Scheduler.default
Historical Data Operations => Rx.HistoricalScheduler
Unit Testing => Rx.TestScheduler
Used right it can improve performance,
used wrong you will kill your app :)
73. Schedulers
testing
Because scheduler has its own virtual clock
Anything scheduled on that scheduler
will adhere to time denoted on the clock
I.e we can bend time for ex unit testing
74. Schedulers
testingvar onNext = Rx.ReactiveTest.onNext;
var scheduler = new Rx.TestScheduler();
var subject = scheduler.createColdObservable(
onNext(100,'first'),
onNext(200,'second')
);
var result;
subject.subscribe((val) => {
result = val;
});
scheduler.advanceBy( 100 );
console.log('Should equal', result === 'first');
scheduler.advanceBy( 100 );
console.log('Should equal', result === 'second');
What happens at what intervals
Advance time
Assert
Advance time
Assert
75. Schedulers
testing
var testScheduler = new Rx.TestScheduler();
var stream = Rx.Observable.interval(1000, testScheduler)
.take(5)
.map((val) => {
return val + 1
})
.filter((i) => {
return i % 2 === 0
});
var result;
stream.subscribe((val) => result = val );
console.log('testing function’);
testScheduler.advanceBy(1000);
testScheduler.advanceBy(1000);
testScheduler.advanceBy(1000);
console.log('Should equal', result === 2);
testScheduler.advanceBy(1000);
testScheduler.advanceBy(1000);
console.log('Should equal', result === 4);
We decide how fast time passes
76. Recipes
Buffer recipe, record interactions on UI
draw where the mouse has been
Replay a game, how a character have moved
left, right, jump, duck
Idea for a project, game where you get to play til you die
and take away move that kills you