├── jsday-2016 ├── img │ ├── IMG_1643.JPG │ ├── IMG_1644.JPG │ ├── IMG_1645.JPG │ ├── IMG_1646.JPG │ ├── IMG_1647.JPG │ ├── IMG_1648.JPG │ ├── IMG_1649.JPG │ ├── IMG_1650.JPG │ ├── IMG_1651.JPG │ ├── IMG_1653.JPG │ ├── IMG_1654.JPG │ ├── IMG_1655.JPG │ ├── IMG_1656.JPG │ └── IMG_1657.JPG ├── workshop.md ├── data-with-d3.md ├── forgotten-funky-functions.md ├── components-in-production.md ├── building-reactive-rchitectures.md ├── out-of-the-browser.md ├── fftt-modern-build-tool.md ├── keynote-day-2.md ├── README.md ├── asynchronous-javascript.md ├── functional-reactive-programming.md ├── higher-order-components-in-react.md ├── keynote-day-1.md ├── day-1.md └── day-2.md ├── progressive-web-app ├── 5_recap.md ├── README.md ├── 3_push-notfication.md ├── 1_intro.md ├── 4_instant-loading.md └── 2_offline-service-worker.md ├── README.md ├── flow-type-slack-conversation.md └── slack-conversation.md /jsday-2016/img/IMG_1643.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbertella/conf-sketches/HEAD/jsday-2016/img/IMG_1643.JPG -------------------------------------------------------------------------------- /jsday-2016/img/IMG_1644.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbertella/conf-sketches/HEAD/jsday-2016/img/IMG_1644.JPG -------------------------------------------------------------------------------- /jsday-2016/img/IMG_1645.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbertella/conf-sketches/HEAD/jsday-2016/img/IMG_1645.JPG -------------------------------------------------------------------------------- /jsday-2016/img/IMG_1646.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbertella/conf-sketches/HEAD/jsday-2016/img/IMG_1646.JPG -------------------------------------------------------------------------------- /jsday-2016/img/IMG_1647.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbertella/conf-sketches/HEAD/jsday-2016/img/IMG_1647.JPG -------------------------------------------------------------------------------- /jsday-2016/img/IMG_1648.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbertella/conf-sketches/HEAD/jsday-2016/img/IMG_1648.JPG -------------------------------------------------------------------------------- /jsday-2016/img/IMG_1649.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbertella/conf-sketches/HEAD/jsday-2016/img/IMG_1649.JPG -------------------------------------------------------------------------------- /jsday-2016/img/IMG_1650.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbertella/conf-sketches/HEAD/jsday-2016/img/IMG_1650.JPG -------------------------------------------------------------------------------- /jsday-2016/img/IMG_1651.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbertella/conf-sketches/HEAD/jsday-2016/img/IMG_1651.JPG -------------------------------------------------------------------------------- /jsday-2016/img/IMG_1653.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbertella/conf-sketches/HEAD/jsday-2016/img/IMG_1653.JPG -------------------------------------------------------------------------------- /jsday-2016/img/IMG_1654.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbertella/conf-sketches/HEAD/jsday-2016/img/IMG_1654.JPG -------------------------------------------------------------------------------- /jsday-2016/img/IMG_1655.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbertella/conf-sketches/HEAD/jsday-2016/img/IMG_1655.JPG -------------------------------------------------------------------------------- /jsday-2016/img/IMG_1656.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbertella/conf-sketches/HEAD/jsday-2016/img/IMG_1656.JPG -------------------------------------------------------------------------------- /jsday-2016/img/IMG_1657.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbertella/conf-sketches/HEAD/jsday-2016/img/IMG_1657.JPG -------------------------------------------------------------------------------- /progressive-web-app/5_recap.md: -------------------------------------------------------------------------------- 1 | # Progressive Web App #PWA - recap by Francesco Bonatesta 2 | 3 | * Push, install, offline 4 | * Speed, permission, hardware 5 | * Think about the objective (re-engage users) and focus on achieving it **progressively** 6 | 7 | 8 | *Slide here* 9 | -------------------------------------------------------------------------------- /jsday-2016/workshop.md: -------------------------------------------------------------------------------- 1 | # Functional and Asynchronous JavaScript Tutorial - jsDay.it 2016 2 | https://github.com/mattpodwysocki/jsday-workshop-2016 3 | 4 | @mattpodwysocki 5 | Open sourcerer 6 | 7 | ## Functional Programming vs imperative 8 | 9 | ## Reactive programming === Collections + Time 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # conferences-sketch 2 | 3 | My personal and opinionated conf notes and sketches. 4 | 5 | ## [Progressive web apps](./progressive-web-app/) 6 | - 04/05/2016 @googleitalia Milan [ita] 7 | 8 | ## Next conferences I'll participate 9 | ### [jsday 2016](./jsday-2016) 10 | - 11, 12/05/2016 Verona [http://2016.jsday.it/](http://2016.jsday.it/) 11 | 12 | ## Contribute 13 | I'll accept pull request about conference I will attend or not if you feel like you can improve my notes feel free to let me know as well 14 | -------------------------------------------------------------------------------- /jsday-2016/data-with-d3.md: -------------------------------------------------------------------------------- 1 | # Discover the information within your data with d3.js | Daniela Mogini 2 | 3 | ## D3 4 | 5 | DOM manipulation: you can do everything you do in jQuery. 6 | - `select`, `selectAll` -> select elements from DOM 7 | - `append` 8 | 9 | Link between data and DOM elements 10 | - `data` 11 | - `enter` 12 | 13 | Array of data are handled natively 14 | 15 | ### Svg elements 16 | ### Scales 17 | Quantitative scales: `d3.scale.linear()`, 18 | ordinal scales: `d3.scale.ordinal()` 19 | Methods for building each of them 20 | 21 | ### Axis 22 | `d3.svg.axis()` 23 | They adapt to fill the data 24 | 25 | ### Colors 26 | ### Transitions 27 | -------------------------------------------------------------------------------- /jsday-2016/forgotten-funky-functions.md: -------------------------------------------------------------------------------- 1 | # Forgotten funky functions by Jakob Mattsson @jakobmattsson 2 | 3 | Javascript everything is so simple, but it has great things. 4 | 5 | ## Functional Programming 6 | function => functional 7 | (function, function) => functional 8 | 9 | Whenever you have a problem you can solve it with another function. 10 | 11 | - `apply` 12 | - `call` 13 | - `arguments` 14 | - `slice` 15 | - `bind` 16 | - ...and clojure 17 | 18 | Stateful function, a function that remember its state. 19 | 20 | ## Meta Programming 21 | - eval 22 | - Function.toString() 23 | 24 | ## There is no class 25 | - new 26 | - MyConstructor 27 | - MyConstructor.prototype 28 | - no types 29 | 30 | ### ES6 or coffeescript syntactic sugar 31 | - class 32 | - constructor 33 | - super 34 | - extends 35 | 36 | Understanding **Object.create** you might not need anymore es6 syntatic's sugar 37 | Oveloading: solve it with passing function to function. 38 | 39 | Object.create CAN be defined. (now is defined ES6?) 40 | -------------------------------------------------------------------------------- /jsday-2016/components-in-production.md: -------------------------------------------------------------------------------- 1 | # (Web?) Components in production | Olga Madejska 2 | 3 | ## Amazon web services 4 | 55 services 5 | 6 | Service teams: 7 | - small 8 | - indipendent (can choose tech stack) 9 | - strong ownership 10 | 11 | No golden hammer, you choose your process, languages, tools. 12 | 13 | ## How to handle differents teams working on the same product 14 | 15 | - Option 1: *Design guide*, implement components in every js framework 16 | - Option 2: *Css framework*, bootstrap style, hard to mantain, set the particular class to particular html 17 | - Option 3: ???, something in code that support all frameworks, browser, performance and accessibility, has tests, development strategy and contribution model 18 | 19 | ### Web Components 20 | Templates, Html import, Custom elements, Shadow DOM 21 | 22 | You can use a polyfill but you have to stick on it 23 | 24 | ## What they kept 25 | - Custom elements 26 | - Style encapsulation 27 | - Defined API 28 | 29 | ## Benefits 30 | Easy to grab for new teams, no longer reviews on the components implementation. 31 | Zero effort after a redesign and sparked community engagement. 32 | -------------------------------------------------------------------------------- /jsday-2016/building-reactive-rchitectures.md: -------------------------------------------------------------------------------- 1 | # Building Reactive Architectures | Matthew Podwysocki 2 | 3 | ## Netflix 4 | Massive query and massive linking across user and data 5 | 6 | @ReactWindows 7 | 8 | @ReactiveX 9 | 10 | Async is awful 11 | 12 | - Living in Callback Hell 13 | - Events and state are mess 14 | 15 | **Promise are only part of solution** 16 | 17 | There is no way to cancel a promise, Fetch API doesn't have an abort method. 18 | 19 | Callback hell solve in the reactive way! 20 | 21 | ## Reactive programming 22 | 23 | - React to load 24 | - React to failure 25 | - React to users 26 | 27 | What's the difference between iterable and events? There is no difference 28 | 29 | Everything is a stream. 30 | 31 | **You must flatMap it.** 32 | 33 | ### story on reactive programming 34 | - jquery: wrong 35 | - knockout or angular: 2 way data binding 36 | - angular 2: implement observables 37 | - ngrx: redux stores in observable way for angular 2 38 | - cycle: unidirectional dataflow reactive programming 39 | - react: subscribe and unsubscribe with rx extension in component mount and unmount 40 | 41 | Observable coming to ES2017?? 42 | Possible standard implementation 43 | 44 | Make reactive great again! 45 | -------------------------------------------------------------------------------- /jsday-2016/out-of-the-browser.md: -------------------------------------------------------------------------------- 1 | # Out of the browser and onto the streets by Ruth John @rumyra 2 | 3 | History of js, lots of stuff happened since 1994 and now we have can speak for days about it 4 | 5 | - Js is being using in aircraft 6 | - Fighthing ebola with offline app 7 | - synthesizer built with javascript 8 | - Move dinosaurs with Raspberry Pi and javascript 9 | 10 | ## Lots of browsers api 11 | Geolocation, Audio, Battery... 12 | 13 | **Winanp** visual engine attach when playing mp3 14 | 15 | *Could I recreate that software in the browser?* 16 | 17 | Web animation API, Html, Css, Canvas, WebGL, video element... 18 | 19 | ### Web animation API 20 | Built on top of css animation, and svg animation, but with js power (timing) 21 | 22 | ### Web audio API 23 | - Create oscillator, that create a sound. 24 | - Grab audio from html 25 | - Create a stream 26 | Then you can create a buffer 27 | 28 | You can then modify the audio 29 | 30 | ### Media stream API 31 | 32 | ### Web MIDI API 33 | Midi is actually music instrument **digital interface** 34 | 35 | Midi -> Message (bits of data) 36 | 37 | Midi instruments, midi controllers, all of them use midi protocol. 38 | 39 | Affordable hardware that you can play with 40 | 41 | Demo -> https://github.com/Rumyra 42 | -------------------------------------------------------------------------------- /progressive-web-app/README.md: -------------------------------------------------------------------------------- 1 | ## 04 aprile 2016 @googleitalia 2 | 3 | # Progressive Web App #PWA 4 | 5 | ### Agenda 6 | * Service worker and offline 7 | * Push notification 8 | * Instant loading e installazione su home screen 9 | * Recap 10 | 11 | ## TOC 12 | - [What are Progressive Web Apps, Alfredo Morresi](./1_intro.md) - [slide](https://drive.google.com/open?id=1IXLWWT9oqkmOfXFNVOI6vX6PMg-OOYnnLsAg4Jw1b7E) 13 | - [Instant and Offline apps with Service Workers - Sivlia Righini](./2_offline-service-worker.md) - [slide](https://drive.google.com/open?id=11QkKWg8843u22YkscY-u6CLGyiXhLdMWfXPJtXprtnA) 14 | - [Service Workers and the offline experience - Maurizio Mangione](./2_offline-service-worker.md) - [slide](https://drive.google.com/open?id=1Mq8FEFl1Arm_h_xtgas9Ngk4DklYVGlBMJQxeEBzLj0) 15 | - [Deeper engagement with Push Notifications - Ludovico Magnocavallo](./3_push-notfication.md) - [slide](https://drive.google.com/open?id=1o74zbm-urcAREqwpIhwArkqcm0w225uoyH7L9UW6hSY) 16 | - [Making it installable and engaging and Instant Loading, Gilberto Cocchi](./4_instant-loading.md) - [slide](https://drive.google.com/open?id=1jkpY7SxCq3XwWKoru7eq0K7zg0YST1NvckXAGbC_3NI) 17 | - [Progressive in Progressive Web Apps, Francesco Bonatesta](./5_recap.md) - [slide](https://drive.google.com/open?id=1YxYzSi75r85zgHnbk94Hd1mZQ_8Np7IND_XLzo4Txpw) 18 | 19 | 20 | ## best link of the day 21 | http://wheel-of-names.appspot.com/static/index.html 22 | -------------------------------------------------------------------------------- /progressive-web-app/3_push-notfication.md: -------------------------------------------------------------------------------- 1 | # Progressive Web App #PWA - Push notification by @ludomagno 2 | 3 | Siti affidabili, veloci e coinvolgenti, attirare l'attenzione dell'utente e migliorare l'interazione con esso. 4 | **Notification Api** 5 | 6 | ## Come strutturare le notifiche per interagire con l'utente 7 | Sette punti simili sia per app che per Web. Una push notification ruba spazio allo schermo quindi si deve utilizzare con cautela. 8 | * Personali, devono rivolgersi all'untente che la riceve, ex. nome della persona che riceve la notifica. 9 | * In tempo reale 10 | * Rilevante per l'utente 11 | * Actionable: deve generare una azione per l'utente 12 | * Concisa 13 | * Funzionare in offline 14 | * Non spammare, no ads in notifiche 15 | 16 | ## Set up 17 | Ci sono due set up diversi, in firefox si ha bisogno solo dell'endpoint, in chrome c'è del setup da fare. 18 | - Developer console, creare un nuovo progetto per avere l'id 19 | - Attivare le api tramite la console e recuperare la browser key 20 | - Nel manifest si andrà ad aggiungere la key 21 | In più serve avere abilitato il service worker. 22 | 23 | ## Processo di subscription 24 | Informare l'utente della subscription creando una storia ad hoc per lui, informarli di come le può limitare o rimuovere. Non fare la subscription alla prima visita del sito ma in un momento chiave come nell'invio di un ordine di un carrello o nel momento della prenotazione di un aereo. Deve essere un valore aggiunto e non spam. 25 | -------------------------------------------------------------------------------- /progressive-web-app/1_intro.md: -------------------------------------------------------------------------------- 1 | # Progressive Web App #PWA - Intro by @rainbowbreeze 2 | 3 | 4 | 5 | ## Storia del web. 6 | * 1991 primo web site. html + css + js 7 | * 2000 Primo step importante introduzione di Ajax. Ajax nasce per far funzionare desktop app nel browser, prima app è stata outlook. 8 | * 2007 Smartphne. Tutto il web adesso è nel palmo della nostra mano. Applicazioni web e applicazioni native 9 | 10 | ## Progressive web app 11 | Si cerca di colmare il gap tra applicazioni native e web app. 12 | Una serie di cose che si possoo implementare un pezzo per volta al fine di ottenere una migliore esperienza utente. 13 | Non tutti i browser supportano le tecnologie base delle progressive web app. Safari per il momento non le supporta per esempio. 14 | ### 3 punti in cui le web app sono peggiori delle native: 15 | * Home screen access: In una progressive web app ti viene chiesto se aggiungere l'icona nell'home screen 16 | * Push notification: Grazie ai service worker è possibile mandare push notification 17 | * Offline: Tramite un proxy che sta in ascolto delle chiamate al server si possono gestire i dati offline 18 | 19 | ## Case histories 20 | * Flip Cart: Ecommerce indiano partito con l'idea di creare una app nativa che ha riprogettato tutto il sito con in mente progressive web app e con grandi risultati. 21 | * Beyond the rack 22 | * Booking.com 23 | 24 | ## Agenda 25 | * Service worker and offline 26 | * Push notification 27 | * Instant loading e installazione su home screen 28 | * Recap 29 | -------------------------------------------------------------------------------- /jsday-2016/fftt-modern-build-tool.md: -------------------------------------------------------------------------------- 1 | # FFTT: A new concept of build tool. | Massimiliano Mantione @m_a_s_s_i 2 | 3 | ## Simple is good 4 | Everybody start with few scripts, but then the project grows 5 | Dependency tracking is what is needing. 6 | 7 | Recipe for speed: 8 | - independency (A, B, C, need A, skip B and C) 9 | - dependency (A > B > C need C skip A, B) 10 | 11 | ## State of the build 12 | - Grunt 13 | - Gulp: pipe 14 | - Broccoli: file tree instead of pipe 15 | - Other tools: 16 | - Webpack: not complete 17 | - Jake: like make 18 | - Gradle: java ecosystem 19 | - Bazel: google 20 | 21 | ## Whishlist 22 | - deterministic 23 | - reliable 24 | 25 | How do determine that a build is reliable? You can't 26 | 27 | ## Dependecy tracking 28 | - file tree (jake, blake) 29 | - internally (gulp, Webpack) 30 | 31 | ## A better way 32 | Track content, not mtime, just how git does. Bazel does it 33 | 34 | ## An even better way 35 | Store everything in a content adressable file. 36 | Use filesystem as environment to build steps. 37 | 38 | Isolate build steps in containers 39 | 40 | ## THe FFTT choice 41 | Fast, correct 42 | 43 | Build system meet functional programming, immutable data structures, memoization of functions result, each step is a pure function. 44 | You never mess with the environment, it's just data transformation other data. 45 | 46 | The build graph is declarative and functional. Each build step is imperative but inside a container, not messing up with system. 47 | Programming language independent. 48 | -------------------------------------------------------------------------------- /jsday-2016/keynote-day-2.md: -------------------------------------------------------------------------------- 1 | # Shipping one of the largest Microsoft JavaScript applications (Visual Studio Code's story) | Keynote by Alexandru Dima @alexdima123 2 | 3 | Visual studio code, made in typescript 4 | 5 | Goal: build a developer experience directly on the browser 6 | Browsers are really good at text layout 7 | 8 | ## Virtual scrolling 9 | Add and remove lines from the Dom 10 | 11 | Sometime Browser are not smart enough you have to use gpu accelerated animation 12 | 13 | ## VS code 14 | - 2014 15 | - Used node-webkit 16 | - 2 hours to put it together 17 | - 6 months to launch 18 | 19 | Started with node-webkit but then passed to `electron` by github. 20 | 21 | Even if you load the code from the same machine bundled and minified code load faster. 22 | 23 | Fast editor - build tools - debugger - git integration 24 | 25 | **April 2015 launch preview** 26 | Monthly updates, people were surprised about editor changing after their feedbacks. 27 | 28 | ### Extension isolation 29 | Controlled extensibility. 30 | 1000 + Extensions built only in javascript/typescript 31 | 32 | ## Language / Debug services 33 | Problem: ctrl + space and have autocomplete, c++ like. 34 | Trying to build the standard based on json, all the language support a single protocol. 35 | 36 | **November 2015 Beta, extensions and open sourced** 37 | Really lot of issues, and some great PRs. 38 | 39 | Try to be transparent as possible, may integration plan, and a roadmap that cover next 6 months. 40 | Questions on stack overflow 41 | Issue on github 42 | 43 | **April 2016 1.0, Localization, Accessibility** 44 | -------------------------------------------------------------------------------- /jsday-2016/README.md: -------------------------------------------------------------------------------- 1 | ## 11 may 2016 Verona 2 | 3 | # jsday 2016 4 | 5 | ### [Agenda](http://2016.jsday.it/schedule/) 6 | 7 | ### Notes 8 | **Day 1** [resume](./day-1.md) 9 | - [What we need from the Web, and what it needs from us](./keynote-day-1.md) 10 | - [Functional and Asynchronous JavaScript Workshop](./workshop.md) 11 | - [Forgotten funky functions by Jakob](./forgotten-funky-functions.md) - [slide](https://speakerdeck.com/jakobmattsson/forgotten-funky-functions-1) 12 | - [Functional Reactive programming](./functional-reactive-programming.md) - [slide](http://www.slideshare.net/flashplatform/reactive-programming-with-cyclejs) 13 | - [Out of the browser and onto the streets](./out-of-the-browser.md) - [slide](https://github.com/Rumyra/JSeverywhere) 14 | 15 | **Day 2** [resume](./day-2.md) 16 | - [Shipping one of the largest Microsoft JavaScript applications (Visual Studio Code's story)](./keynote-day-2.md) 17 | - [Building Reactive Architectures](./building-reactive-rchitectures.md) 18 | - [Discover the information within your data with d3.js](./building-reactive-rchitectures.md) 19 | - [The Evolution of Asynchronous JavaScript](./asynchronous-javascript.md) - [slide](http://www.slideshare.net/cirpo/the-evolution-of-asynchronous-javascript-61984337) 20 | - [(Web?) Components in production](./components-in-production.md) 21 | - [FFTT: A new concept of build tool](./fftt-modern-build-tool.md) 22 | - [Higher Order Components in React](./higher-order-components-in-react.md) - [slide](https://speakerdeck.com/cef62/higher-order-components-in-react-at-italian-jsday-2016) 23 | - A Class Action [slide](http://www.slideshare.net/unlucio/a-class-action) 24 | -------------------------------------------------------------------------------- /jsday-2016/asynchronous-javascript.md: -------------------------------------------------------------------------------- 1 | # The Evolution of Asynchronous JavaScript | Alessandro Cinelli @cirpo 2 | 3 | Asynchrony now and later 4 | 5 | 6 | ## Concurrency 7 | Executing small pieces of code independently one from another. 8 | 9 | JS running in a hosting environment. 10 | 11 | JS is single thread, sort of concurrency, but hosting environment can use different thread 12 | 13 | ## Asynchrony 14 | 15 | Async is great but can be hard 16 | Human being has a sequential brain, we are not multi-tasker 17 | 18 | Callbacks works well and you can solve the callback hell without being lazy. 19 | Getting a value in a synchronous way is like pull a data from somewhere 20 | 21 | Async callback is like push values 22 | 23 | Error handling, Inversion of control, How can you tell it's async? 24 | 25 | ### Promises 26 | Promise represent a proxy for a value, it associate handlers on a single value. 27 | 28 | ES2015 jobs -> free pass on the rollercoaster of event loop. 29 | Mechanism inside js engine to go async 30 | 31 | Promise are now the official way to provide async. 32 | 33 | Object with three state Pending, fulfilled, rejected 34 | - `.then()` method to be able to access to the value fulfilled 35 | - `.catch()` method to handle Error 36 | 37 | Control flow: solved 38 | Inversion of control: solved 39 | Error handling: solved 40 | Async or sync: solved 41 | 42 | But... 43 | 44 | **Promise hell** 45 | 46 | Don't use promise for controlling the flow. 47 | #### Single Value 48 | Single resolution is bad for streams, with promise you will handle a single value 49 | 50 | #### Performances 51 | Promises are slower than callback, but it's not gonna be an issue in 99,9% of the time. 52 | 53 | ### Generators 54 | New type of function that doesn't have the run-to-completion behaviour of the other function. 55 | 56 | The yeald is pausing the function! You have full controll on those functions. 57 | 58 | Iterators are just one side, the other side is observables. 59 | 60 | We can block, we can pull values, we can push values. 61 | 62 | **Generators + Promises** for the win. 63 | 64 | #### Problem, we need a library to run the generators. 65 | **ES7 ES2016 => async / await** finally something inside the language itself 66 | 67 | callbacks, then, async/await, highland (rx.js, streams) 68 | -------------------------------------------------------------------------------- /progressive-web-app/4_instant-loading.md: -------------------------------------------------------------------------------- 1 | # Progressive Web App #PWA - Making it installable and Instant loading by Gilberto Cocchi 2 | 3 | ## Installare la web app sul proprio dispositivo 4 | Il Manifest viene usato anche per definire come salvare sul proprio device android la web app. File json di configurazione. 5 | 6 | * Utente va nel sito, clicca sul menu di chrome add to home screen e scarica il Manifest 7 | * Gli viene chiesta conferma 8 | * Un icona viene installa sulla home screen 9 | 10 | La web app a questo punto si apre in full screen senza dover aprire il browser. Si può abilitare o meno la barra degli indirizzi. 11 | 12 | Si può fare l'auto prompt che permette all'utente di salvare il sito sull'home screen senza passare dalle impostazioni di chrome. Questo è abilitato di default su chrome mobile se si naviga su un sito per almeno 2 volte con una distanza di non più di 5 minuti(??). 13 | 14 | Lato sviluppo questa cosa si può controllare per renderla più user friendly. 15 | 16 | ## Instant loading 17 | Ogni step che un utente deve fare fa perdere il 20% di essi 18 | 19 | * Compression: minificazione, immagini webp(funziona solo su chrome praticamente) 20 | * Round Trips: domini esterni, link attribute rel, prefetch etc, Caricamento di javascript, attributi *defer* o *async* 21 | * Strategia di Cache: header del server last-modified, etag, if-modified-since, if-none-match, cache-control, expires 22 | Come definire **cache-control** e definire una max age? 23 | Usare un framework che pone un hash sul file di modo da settare max age su years. index.html con master-validate quindi cache breve 24 | * CDNs 25 | 26 | HTTP/2 esperimento di google engeneers 27 | In http si può fare una connessione tcp alla volta e il canale non si può utilizzare se è già presente una connessione tcp. 28 | Http/2 utilizza una sola connessione ma le richieste diventano degli stream, tante richieste di file piccoli vengono concatenati in un unica connessione. Si possono inviare dati che hanno origine diversa. 29 | Multiplexing della stessa connessione che a loro volta vengono divisi in frames con diversi headers, gli headers ripetuti fra loro vengono salvati in cache e non vengono ripetuti. 30 | Retrocompatibile con http. 31 | 32 | ## Recap 33 |  34 | -------------------------------------------------------------------------------- /jsday-2016/functional-reactive-programming.md: -------------------------------------------------------------------------------- 1 | # Functional Reactive programming with React.js by Luca Mezzalira 2 | 3 | - Reactive programming 4 | - Model view intent 5 | - cycle.js 6 | 7 | ## Imperative, Functional, Reactive 8 | - Imperative: Describing step by step what you want to achieve. Object has a state 9 | - Functional: Manipulate data in the argument of the function, but you can't manipulate the initial data 10 | - Reactive: Moving forward, used in backend development, in front end is quite new. 11 | 12 | ## Imperative vs Reactive 13 | Reactive, less code, more readable. 14 | 15 | - Observable pattern 16 | - Iterator pattern 17 | 18 | ### [RxJs](http://reactivex.io/) 19 | Start learning few concepts to understand reactive programming. 20 | 21 | **streams**: sequence of ongoing events, everything can be a stream. 22 | It can emit three different things value, error, or completed signal, (3 callbacks) 23 | 24 | **cold observables**: waits until an observer subscribes to it before it begins to emit items 25 | **hot observables**: emitting items as soon as it is created 26 | **operators** 27 | 28 | ## Architectures timeline 29 | - '80 MVC 30 | - '90 MVP 31 | - 2005 MVVM 32 | - 2009 DCI (data context and interaction) 33 | - 2013 FLUX 34 | - 2015 MVI (Model view intent) 35 | 36 | ### MVI 37 | You can't call a method from another module, they are separated, the only shared part of modules are observables. 38 | Better separation of concerns, dependency injection, app easier to test, all the states inside models, the view is state free. 39 | **View -> Render** 40 | View is preparing the virtual tree 41 | There is another library that will render the dom. 42 | 43 | View is receiving data from model, pass them as output to the render 44 | 45 | **Intent** 46 | Input: raw input from user 47 | Output to the model 48 | 49 | **Model** 50 | Input: data from the intent and store them 51 | 52 | ## Cycle.js 53 | Your application is a pure function, that receive an input and return an Output 54 | 55 | Core concepts: 56 | - Object 57 | - Functions 58 | - Drivers 59 | - Helpers 60 | - Components 61 | 62 | **Drivers** When you have to do something, is better to create a Driver 63 | 64 | - Drivers focus on interface for effects 65 | - It doesn't contain business logic 66 | - It receive inputs and return outputs in a predictable way. There can be read only or write only but they are edge cases 67 | 68 | Reactive programming using when you need to fetch lots of data from the back end 69 | 70 | What developers needs to know about MVI [link](http://thenewstack.io/developers-need-know-mvi-model-view-intent/) 71 | -------------------------------------------------------------------------------- /progressive-web-app/2_offline-service-worker.md: -------------------------------------------------------------------------------- 1 | # Progressive Web App #PWA - Service worker by Silvia Righini - Offline by @granze 2 | 3 | # Service worker 4 | Worker che intercetta le richieste http, funziona in un thread separato e non ha accesso al dom. 5 | Unico vincolo per utilizzare service worker, si possono registrare solo su server con https. 6 | 7 | ## Registrare un service worker 8 | ```javascript 9 | if (navigator.serviceWorker) { 10 | navigator.serviceWorker.register('/sw.js', { 11 | scope: "/" 12 | }); 13 | } 14 | ``` 15 | Possiamo rimanere in ascolto di 3 diversi eventi come per esempio *fetch*, *push* e *sync* 16 | ```javascript 17 | self.addEventListener('fetch', event => { 18 | console.log(event.request) 19 | }) 20 | ``` 21 | Il service worker verifica se una versione è differente da quella che ha salvato e nel caso modifica la pagina. 22 | 23 | # Offline 24 | SW: api di basso livello e event driven. 25 | L'evento di fetch permette di controllare le richieste che vanno alla rete. Per esempio possiamo decidere di usare una versione cachata delle risorse. 26 | 27 | 2012 Application cache, api di alto livello non permette di controllare veramente le risorse che si vogliono rendere disponibili offline. **DEPRECATA** 28 | 29 | Nuova **Cache Api** messa a disposizione dai service worker: 30 | ```javascript 31 | const urlsToCache = ['/js/main.js', '/css/main.css'] 32 | 33 | self.addEventListener('install', event => { 34 | event.waitUntil( 35 | caches.open('static-v1').then(cache => ...) 36 | ) 37 | }) 38 | ``` 39 | ## Perché "cacheare" 40 | Per rendere disponibile una app offline, ma non solo per far credere a un utente che una app sia performante anche se non per forza lo è. 41 | Page shell, scheletro dell'applicazione da mostrare all'untente prima che l'app si sia caricata. 42 | 43 | ## Strategie di cache 44 | * Cache only 45 | * Network only 46 | * Cache first, falling back to network 47 | * Network first, falling back to cache: caso d'uso se si hanno risorse da aggiornare frequentemente. Problema possibile di timeout. 48 | * Cache then network: app di twitter 49 | 50 | ## sw-precache 51 | Libreria di google per generare un sw data una lista di path di file da cacheare. Ogni risorsa aggiunta viene aggiornata una hash md5 per tenere conto della versione. 52 | 53 | ## sw-toolbox 54 | Libreria che permette di gestire al meglio la nostra strategia di cache. 55 | 56 | ```javascript 57 | importScripts() 58 | ``` 59 | ritorna un oggetto toolbox. Migliore debug, api per gestire una get con un timeout. 60 | 61 | ```javascript 62 | toolbox.options.debug = true 63 | toolbox.router.get('/api', toolbox.networkFirst) 64 | ``` 65 | 66 | Thank you @granze 67 |  68 | -------------------------------------------------------------------------------- /jsday-2016/higher-order-components-in-react.md: -------------------------------------------------------------------------------- 1 | # Higher Order Components in React | Matteo Ronchi 2 | 3 | First of all web was a document 4 | 5 | jquery changed the web, it become dinamyc 6 | 7 | Angularjs change the approach, directive first attemp to encapsulate a component 8 | Separation of concern in technology 9 | 10 | React, took the template and bring it inside the javascript. 11 | 12 | ## All modern frameworks are component oriented 13 | 14 | Everything can be a component, an application is a tree of components 15 | **Component**: Composable, encapsulated, reusable, easy to design 16 | 17 | ## React 18 | 2 kind of component 19 | 20 | ### Presentational component 21 | small, reusable, *pure function* => Easy to test 22 | Stateless functional components: 23 | `const Label = (props) =>
14 | 15 | 16 | 2 talks, a workshop and mentions in many talks, all about *Functional reactive programming*. 17 | 18 | # Day 1 19 | ## First Keynote: What we need from the Web, and what it needs from us. 20 | [@shwetank](https://twitter.com/shwetank), Opera developer, talked about *Progressive web apps*, probably the second big thing in javascript 2016. It was fun because I just attended another great conference at google Italia few days before the jsday on the exactly same topic. I was thinking *PWA* were a Google mostly-only thing but I was happy to realize other browsers thinking about it as a way to save `the web` against `mobile native` development. 21 | 22 | How *PWA* can beat native? 23 | Basically web offer: `try before install` model vs native that force you to install an app to try it. 24 | 25 | Pretty much same capabilities and user engagement without even the needs of installing. 26 | 27 | - Add to home screen 28 | - Work offline 29 | - Push notifications 30 | - Plus the web's power: different urls, SEO, accessibility... 31 | 32 | With *PWA* you let the user choose and that for @shwetank can be the key. 33 | 34 | ## Functional Programming and Async Programming Workshop 35 | The topic was tempting but then after a short and interesting introduction from [@mattpodwysocki](https://twitter.com/mattpodwysocki) people lost interest. 36 | 37 | Everybody was following the exercise from the reactivex [site](http://reactivex.io/learnrx/), that I really encourage you to do, but I'd rather have done it at home than spenging my time there during the conference. 38 | 39 | Not to criticise him or the organization but just to remind myself it may be better to focus on talks. 40 | 41 | Anyway presentation's slide can be found [here](https://github.com/mattpodwysocki/jsday-workshop-2016) along with all the other assets and I encourage you to check them out. 42 | 43 | ## Forgotten funky functions 44 | [@jakobmattsson](https://twitter.com/jakobmattsson) gave a quick talk about javascript in general and what you can easily accomplish with function that you could have even forgotten. In javascript everything seems really simple, but still you can do great things. 45 | 46 | He talked about 3 main topics: 47 | - functional programming 48 | - meta programming 49 | - there is no class 50 | 51 | > Whenever you have a problem you can solve it with another function. 52 | 53 | @jakobmattsson discuss about `apply`, `call`, `clojures`, `eval`. Topics that (almost) every js developer has doubt about. 54 | 55 | He concluded with a useful explanation on ES6 or coffeescript classes syntactic sugar that you may not need if you first fully understand **Object.create**. 56 | 57 | ## Functional Reactive programming with React.js 58 | **Spoiler alert**, [@lucamezzalira](https://twitter.com/lucamezzalira) didn't talk about react at all! At the end he talked about cycle.js but it was a good *excursus* about RxJs. 59 | 60 | You have to start learning a few concepts to understand reactive programming, like *streams*, [cold and hot observables](http://reactivex.io/documentation/observable.html) and [operators](http://reactivex.io/documentation/operators.html). 61 | 62 | If you are using a *Flux* implementation for your front end architecture or even worst MVC / MVVM / MV* pattern, you are living in the past! Say hello to **MVI** aka [Model View Intent](http://thenewstack.io/developers-need-know-mvi-model-view-intent/). 63 | 64 | I'm personally quite happy with *Redux* for now but I think you need at least to know what's going on around you. 65 | 66 | The conclusion was that *Functional Reactive programming* isn't always the best thing to do but for sure it's great when you need to fetch lots of data and react. 67 | You can find slides [here](http://www.slideshare.net/flashplatform/reactive-programming-with-cyclejs). 68 | 69 | ## Out of the browser and onto the streets 70 | [@Rumyra](https://twitter.com/Rumyra) did the most pleasant talk of the day, with music and visual, it was party time already! 71 | 72 | Apparently she's [VJing](https://github.com/Rumyra/VJing) around projecting visual animations on buildings along with music. I'd love to see her live. Unfortunately she haven't had the chance to do it during the party in Verona, but maybe next year 😀. 73 | 74 | She talked about the newest web APIs such as `animation`, `audio`, `strem` and `midi`. I encourage you to have check her [github](https://github.com/Rumyra) account. It's not that easy to find samples but you can have an idea about her projects. 75 | 76 | She showed us a demo with voice control using a microphone and then another mixing music, video and visual animation. 77 | 78 | Last she ended up showing her handmade bag with a mac and her "mini" MIDI controller inside that she's using for VJing. 79 | 80 | # Still interested in [day 2](./day-2.md)? 81 | -------------------------------------------------------------------------------- /flow-type-slack-conversation.md: -------------------------------------------------------------------------------- 1 | Curiosità: come gestite scenari in cui avete una factory che produce oggetti e volete verificare che gli oggetti siano del tipo che volete? 2 | 3 | 1. usate semplicemente un campo pesudo privato tipo `obj.isMyFuckingObj = true` 4 | 2. usate un campo pubblico con un Symbol come valore `obj.isMyFuckingObj = Symbol('myFuckingObjKey')` 5 | 3. usate una classe per sfruttare `instanceof` 6 | 4. controllate che l’oggetto abbia i metodi/fields che vi aspettate e quindi rispetti l’interfaccia pubblica che vi aspettate 7 | 8 | agos [9:29 AM] 9 | 5. uso un linguaggio con un check statico dei tipi? :stuck_out_tongue: 10 | 6. scrivo un test (edited) 11 | 12 | cef62 [9:34 AM] 13 | > scrivo un test 14 | assolutamente :wink: 15 | 16 | > 5. uso un linguaggio con un check statico dei tipi 17 | non è un opzione :wink: 18 | 19 | rickdrink [9:51 AM] 20 | gli oggetti a @cef62 li prepara Samuel L. Jackson 21 | 22 | agos [9:55 AM] 23 | non aggiungerei un campo, piuttosto testerei il comportamento dell'oggetto 24 | 25 | cef62 [9:57 AM] 26 | concordo, infatti se non ho istanze di solito tendo a controllare l’interfaccia dell'oggetto 27 | solo in dev-mode però non in produzione 28 | 29 | gcanti [10:17 AM] 30 | @cef62 userei una classe + `instanceof` (metodo nominale) oppure una libreria per il type checking (metodo strutturale) 31 | quindi 3) o 4) 32 | 33 | cef62 [10:17 AM] 34 | +:+1: la tua lib è in top alla lista per scenari complessi :slightly_smiling_face: (edited) 35 | 36 | dej611 [10:19 AM] 37 | duck typing (4) (edited) 38 | 39 | cef62 [10:19 AM] 40 | per le classi preferirei evitare di avere istanze se possibile 41 | quindi `instanceof` è molto utile ma se posso seguo alternative :wink: 42 | 43 | gcanti [10:20 AM] 44 | lo strutturale è più costoso ma lo puoi eseguire solo in dev 45 | 46 | cef62 [10:20 AM] 47 | assolutamente 48 | è un check che mi interessa solo in sviluppo 49 | in produzione lo ignoro in ogni caso 50 | 51 | gcanti [10:21 AM] 52 | se già usi babel e non vuoi lasciare "nessun segno" nella codebase puoi dare un'occhiata ai plugin di babel che fanno type checking 53 | 54 | cef62 [10:22 AM] 55 | si li conosco ma preferisco qualcosa di esplicito, semplicemente rimuovo le espressioni condizionali con NODE_ENV === ‘development' 56 | sto solo indagando le preferenze e le diverse tecniche :slightly_smiling_face: 57 | è sempre interessante vedere come altri affrontano situazioni comuni ma non per forza banali :wink: 58 | 59 | dej611 [10:27 AM] 60 | ieri hanno pubblicato un articolo su come integrare `flow` in un progetto che già utilizza babel 61 | 62 | cef62 [10:27 AM] 63 | questo dici? 64 | https://medium.com/@thejameskyle/using-flow-with-babel-c04fdca8d14d#.v2eo3chr3 65 | 66 | dej611 [10:27 AM] 67 | si 68 | 69 | cef62 [10:30 AM] 70 | si è molto interessante 71 | 72 | dej611 [10:32 AM] 73 | un qualcosa così ti risolverebbe le cose meglio del duck typing o dell’`instanceof` (che può essere facilmente ingannato) 74 | 75 | cef62 [10:33 AM] 76 | verissimo 77 | ma come team è stato deciso di non usare un type checker al momento 78 | quindi per ora è un opzione che lascio da parte 79 | 80 | pigoz [10:34 AM] 81 | al momento io sto usando tcomb, ma penso che presto farò il salto 82 | tenendo comunque tcomb con il plugin 83 | 84 | cef62 [10:34 AM] 85 | devo essere sincero che scrivere JS definendo i tipi mi lascia perplesso :confused: 86 | non per i vantaggi 87 | 88 | pigoz [10:35 AM] 89 | la cosa che non mi era piaciuta di flow al tempo, era che non c'era check a runtime 90 | 91 | cef62 [10:35 AM] 92 | ma a pelle XD 93 | 94 | dej611 [10:35 AM] 95 | ma flow funziona anche senza definizione dei tipi 96 | con le definizioni funziona meglio, ma il motore sotto, almeno prima, inferiva il tipo 97 | 98 | pigoz [10:36 AM] 99 | infatti anche a me lascia perplesso, ma infatti tcomb non è proprio un sistema di tipi, ma piu' un sistema di contratti 100 | 101 | cef62 [10:36 AM] 102 | ma con le dipendenze di 3° parti come funziona ora? 103 | 104 | pigoz [10:36 AM] 105 | e lo trovo estremamente utile 106 | 107 | cef62 [10:36 AM] 108 | devi dichiararle? o le ignora se non le mappi 109 | 110 | dej611 [10:37 AM] 111 | c’è spiegato nell’articolo 112 | 113 | cef62 [10:37 AM] 114 | :wink: non lo ho ancora letto era nei preferiti, tnx 115 | flow è parecchi mesi che non lo guardo 116 | 117 | dej611 [10:37 AM] 118 | puoi o definirle tu, o scaricarle da un repo 119 | 120 | cef62 [10:37 AM] 121 | ma se non le voglio? 122 | 123 | dej611 [10:37 AM] 124 | ma immagino che altrimenti il motore cerchi di capirlo 125 | non saprei 126 | 127 | cef62 [10:38 AM] 128 | tnx :wink: mi informerò 129 | 130 | gcanti [10:39 AM] 131 | attenzione però che per come funziona l'inferenza di flow potreste avere risultati sorprendenti a prima vista, occorre metterle le type annotation, almeno in punti strategici 132 | questo ad esempio non solleva errori `const a = [1, 2, 3]; a.push('s')` 133 | perchè flow, in assenza di annotazioni, inferisce il tipo dall'uso. Sopra `a` ha tipo `ArrayRecap from #jsday 2016 #functional #reactive #programming is the new black #javascript
— Daniele Bertella (@_denb) 12 maggio 2016
33 | 34 | 35 | ## Discover the information within your data with d3.js 36 | Not much to say about it, it was a really entry level talk by Daniela Mogini. 37 | 38 | Some insights on how to manipulate DOM, handling Array of data natively in D3js. 39 | 40 | The entry slogan was good: `this has nothing to do with jQuery` but it seems a lot like it to me in general. 41 | Don't get me wrong, I know that D3.js it's really powerful but at the end of this talk I haven't feel much of its awesomeness. 42 | 43 | ## The Evolution of Asynchronous JavaScript 44 | [@cirpo](https://twitter.com/cirpo) gave us another really good talk about async in javascript. 45 | 46 | He started with history, how cool callbacks can be and how, if you aren't a lazy developer, you can avoid the feared callback hell. 47 | 48 | He Talked about *Promises*, of course, and how they become the official way to provide async in js today. 49 | But *Promises* aren't always the best choice, you don't use them in flow control. You can end up easily with a **Promise Hell** if you don't pay attention. 50 | 51 | > **Generators + Promises** for the win. 52 | 53 | *Generators*, a new type of function that doesn't have the *run-to-completion* behaviour of the other functions. 54 | They have a *yield* keyword that can pause/restart the flow and you have full control on it. 55 | 56 | Unfortunately you have to import libraries to use them but seems like the next javascript, ES7 (ehm ES2016), will ship async / await natively. 57 | You can start playing with it using babel (or typescript). 58 | ``` 59 | npm install -g babel-cli 60 | npm install babel-plugin-transform-async-to-generator 61 | 62 | //add it either to .babelrc or package.json 63 | { 64 | "plugins": ["transform-async-to-generator"] 65 | } 66 | 67 | babel a.es6 -o a.js 68 | node a.js 69 | ``` 70 | 71 | > CHOOSE YOUR CONCURRENCY MODEL 72 | - callbacks 73 | - promises 74 | - async/await 75 | - highland (RxJs, streams) 76 | 77 | ## (Web?) Components in production 78 | [@olamad313](https://twitter.com/olamad313) is a UX Designer at Amazon Web Services and gave us a great view about how they handle components in their teams across the world. She didn't speak about libraries or polyfill (*Polimer* for example), they don't actually use one apparently because they didn't want to depend on it. 79 | 80 | They build their components using plain javascript embracing web components philosophy and then they also build the bridge to connect them with frameworks or libraries their teams choose to use (GWT, Angular, and React). 81 | 82 | They keep principles like custom elements and style encapsulation from web components and they reached few benefits: 83 | - Components are easy to grab for new teams. 84 | - No longer need to review the components final implementation in production. 85 | - Little effort after a component redesign 86 | - A sparked community engagement. 87 | 88 | ## FFTT: A new concept of build tool 89 | [@m_a_s_s_i](https://twitter.com/m_a_s_s_i) talked about his side project, and invite every one (who can understand what is it about) to contribute on it. Basically he's building his own build tool to replace `grunt`, `gulp` or `webpack` (I'm writing only the most famous). 90 | Unsatisfied with the job those tools are doing @m_a_s_s_i writes his own to accomplish what he really needs: a fast, deterministic, reliable and language agnostic build tool. 91 | 92 | The build system meet functional programming, immutable data structures, memoization of functions result, each step is a pure function. 93 | You never mess with the environment, it's just data transformation. 94 | The build graph is declarative and functional. Each build step is imperative but inside a *container*, so you don't mess up with system. 95 | 96 | It's built with not many lines of javascript but it's totally programming language independent. 97 | 98 | It's not ready for production yet but feel free to contribute if you are interested in it! 99 | 100 | Here the github [link](https://github.com/massimiliano-mantione/fftt) 101 | 102 | ## Higher Order Components in React 103 | Finally React :-D. Thanks to [@cef62](https://twitter.com/cef62). 104 | 105 | After an excursus on React in general, and the component concept in particular we learn how to extend a component using an high order one. 106 | 107 | He spoke about mixins (deprecated with ES6 syntax) as well and he gave us a good `HoC vs Mixins` preview: 108 | - Declarative vs Imperative 109 | - Customizable vs Favors inheritance 110 | - Easy to read vs Hard to read 111 | - Enforce encapsulation 112 | 113 | He explains *high order function* as functions that accept a function as an argument and return another function. 114 | 115 | So HOC are high order functions that, instead, return a component. 116 | 117 | ## A Modern debugging experience using DevTools by [@umaar](https://twitter.com/umaar), modern techniques for debugging JavaScript code. 118 | 119 | Umar covered different ways to debug our code using the Chrome DevTools. 120 | For example he explained how to: 121 | - Use Quick Source Pane for faster CSS editing 122 | - Trigger pseudo classes in DevTools 123 | - Use the animation inspector to change and modify running animations 124 | - Try out the official DevTools dark theme 125 | - Copy the response of a network resource to your clipboard 126 | and much more! 127 | 128 | You can find all this techniques explained in his [slides](https://umaar.github.io/devtools-animated-2016) 129 | 130 | ## A Class Action 131 | Last talk of the conference by [@unlucio](https://twitter.com/unlucio), a dispute on probably the most controversial feature in ES2016: the `class` keyword. 132 | 133 | He called few witnesses for the *dispute*: 134 | - `miss function`: do we really need a shorthand for manually defining a constructor Function? 135 | 136 | - `the prototype`: If you want to write once and use your code in multiple situation, prototypal inheritance makes this easy. 137 | - `class`: does it really add something new to the language and will she simplify everybody's life? 138 | 139 | *OOP is good for you... at least that what they say* 140 | 141 |  142 | 143 | For code segregation choose `modules` over `classes` 144 | 145 | I liked the reference to the coffee and sugar: 146 | 147 | > When coffee is good you don't need sugar, and `class` seems more like aspartame than sugar. 148 | > The difference is that aspartame can kill you! 149 | 150 | To sum up, it was a really nice conclusion of these wonderful two days conference in Verona. 151 | I encourage you to have a look at [slides](http://www.slideshare.net/unlucio/a-class-action) that are self explanatory. 152 | -------------------------------------------------------------------------------- /slack-conversation.md: -------------------------------------------------------------------------------- 1 | # React channel 2 | 3 | ## Idee su come gestire l'ereditarietà del `context`, con la possibilità di fare modifiche da un certo punto della app in poi 4 | 5 | Matteo Ronchi [10:16 AM] 6 | @gianmarcotoso @michele @lucacolonnellocrweb e chiunque altro abbia input utili, ho una domanda per voi: 7 | Supponete di avere un manager/oggetto che ha dei valori che sono esposti via `context` ai children. Ma vorreste che alcuni rami usassero delle diverse configurazioni di valori. Ovviamente se ogni componente che usa questi valori ha nozione della chiave che deve chiedere all’oggetto nel context funziona tutto ma supponiamo che io volessi definire solo nel nodo *X* un nuovo set di valori e imporre a tutti i children/descendant questo set di valori ma senza passare una chiave esplicita ad ogni componente descendant… 8 | L’uso del `context` è opzionale se ci sono altri approcci che funzionano 9 | 10 | **TL,DR;** per riassumere la radice ha 4 figli e 3 ricevono il colore rosso, ma uno e tutti is uoi children voglio ricevano blue definendolo solo in quel nodo padre di quel ramo 11 | 12 | Michele Bertoli [10:20 AM] 13 | bhe' il context funziona gia' cosi' nel senso di sovrascrivere i valori per i figli 14 | 15 | Matteo Ronchi [10:21 AM] 16 | si ma è globale no? 17 | cioè se sovrascrivo anche gli altri rami ricevono la modifica 18 | o clona ad ogni step (ammetto che non ho verificato) 19 | ma mi sembra molto costoso in termini di risorse clonare il context... 20 | anche lo facesse solo `shallow` 21 | 22 | Luca Colonnello [10:23 AM] 23 | ho capito 24 | al di là del modo, il context ha un problema a riguardo 25 | il figlio deve definire cosa vuole che i suoi figli vedano 26 | quindi fondamentalmente per come funziona ora con l’attuale context di react penso ci sia troppo effort da distribuire 27 | se invece creassi un container? 28 | 29 | Matteo Ronchi [10:24 AM] 30 | aspe 31 | il context fa quello che mi serve 32 | 33 | Luca Colonnello [10:24 AM] 34 | certo 35 | 36 | Matteo Ronchi [10:24 AM] 37 | la radice definisce nel context `color` 38 | e tutta l’app li riceve 39 | 40 | Luca Colonnello [10:24 AM] 41 | si 42 | 43 | Matteo Ronchi [10:24 AM] 44 | se poi un nodo aggiunge altri valori solo i suoi figli li vedranno (edited) 45 | 46 | Luca Colonnello [10:24 AM] 47 | certo 48 | 49 | Michele Bertoli [10:24 AM] 50 | http://www.react.run/rJ4F2T-t/2 (edited) 51 | 52 | Matteo Ronchi [10:25 AM] 53 | ma `color` lo vedranno sempre 54 | 55 | Luca Colonnello [10:26 AM] 56 | ma tu vuoi che color sia diverso solo da un certo nodo in poi e non vuoi specificarlo in quel nodo ma nel padre di tutti giusto? 57 | 58 | Michele Bertoli [10:26 AM] 59 | > e non vuoi specificarlo in quel nodo ma nel padre di tutti 60 | ah ok non avevo capito 61 | 62 | Matteo Ronchi [10:26 AM] 63 | @michele si l’idea è quella 64 | immaginatevi lo scenario 65 | parliamo di un theme-manager per esempio 66 | anche se si può applicare a tanti casi (edited) 67 | l’app usa il tema `white` 68 | ma voglio che una modale e tutto il suo contenuto usi il tema `red` 69 | però non tutti i nodi della modale sono consapevoli del `theme-manager` 70 | quindi non posso semplicemente passare dalla modale ai figli che il tema è `red` e cmq passare la prop esplicitamente non mi piace (edited) 71 | l’esempio di Michele è nella direzione che desidero 72 | ora devo vedere se funziona anche con oggetti e non solo plain props 73 | però questo espone il fatto che il context viene ricalcolato potenzialmente ad ogni render 74 | e non mi piace molto 75 | @michele: fighissimo react.run :slightly_smiling_face: 76 | 77 | Michele Bertoli [10:29 AM] 78 | http://www.react.run/rJ4F2T-t/3 (edited) 79 | funziona anche con oggetti 80 | 81 | Matteo Ronchi [10:30 AM] 82 | @michele quindi ogni ramo può sovrascrivere valori senza impatatre gli altri rami (edited) 83 | questo non lo sapevo 84 | 85 | Michele Bertoli [10:30 AM] 86 | @cef62: yep 87 | l'ho scoperto qui: https://twitter.com/ryanflorence/status/717597674040467456 88 | Ryan Florence @ryanflorence 89 | @MicheleBertoli cool, but I think you are now limited to a single Provider in the app, no? The second you provide twice it shadows __data. 90 | TwitterApril 6th at 8:19 AM 91 | 92 | Matteo Ronchi [10:33 AM] 93 | figo @michele! 94 | 95 | Luca Colonnello [10:30 AM] 96 | ok allora io ti prppongo questo: 97 | crei un themeManager locale 98 | o meglio un themeManager globale che in pattern factory possa essere ricreato a partire dall’oggetto base con config differenti 99 | 100 | Matteo Ronchi [10:31 AM] 101 | @lucacolonnellocrweb: una cosa, io non posso sapere sempre che c’è un override eslicito 102 | mi spiego 103 | la dialog che usa `red` contiene altri container e alcuni dei loro children accedono al theme mangare, per fare override dovrebbero essere consapevoli del cambio di tema 104 | quindi deov cmq usare il context 105 | 106 | Luca Colonnello [10:32 AM] 107 | no beh certo 108 | ma se il themeManager è un istanza inserita nel context 109 | che tutti usano e da cui recuperano variabili tipo il color 110 | basta solo reistanziare il theme manager con config differenti nel nodo dal quale vuoi si applichi il tema red 111 | e tutti i figli lo useranno indipendentemente da quello che il padre ha impostato 112 | sbaglio? 113 | 114 | Matteo Ronchi [10:33 AM] 115 | mmmm io mi immagino (visto che michele ha sdoganato l’override x nodi) 116 | che la radice inietta un unico them manager nell'app 117 | e ha un default theme 118 | 119 | Luca Colonnello [10:33 AM] 120 | si 121 | esatto 122 | 123 | Matteo Ronchi [10:34 AM] 124 | poi il nodo dialog modifica il valore del theme da `white` a `red` 125 | 126 | Luca Colonnello [10:34 AM] 127 | esatto 128 | quello intendevo 129 | 130 | Matteo Ronchi [10:34 AM] 131 | e tutti i suoi figli, che accedono all’unico theme manager 132 | 133 | Luca Colonnello [10:34 AM] 134 | forse mi sono spiegato male 135 | 136 | Matteo Ronchi [10:34 AM] 137 | useranno red 138 | 139 | Luca Colonnello [10:34 AM] 140 | il problema è che devi creare un nuovo theme manager 141 | perchè se no le modifiche hanno effetti anche sui padri 142 | quindi il figlio dovrebbe fare tipo 143 | 144 | Matteo Ronchi [10:34 AM] 145 | no non è vero, basta che il them manager supporti + temi 146 | e tu gli chiedi il tema tramite la chiave 147 | 148 | roberto diana [10:35 AM] 149 | ... of topic ... ma il context non verrà abbandonato in futuro ? .. 150 | 151 | Matteo Ronchi [10:35 AM] 152 | abbandonato difficilmente 153 | potrebbero cambiare le API 154 | se tolgono la DI in react perdono accesso a tutte le cose fighe che si stanno producendo 155 | 156 | Luca Colonnello [10:35 AM] 157 | 158 | ``` 159 | class First extends React.Component { 160 | getChildContext() { 161 | return { themeManager: this.context.themeManager.clone({ 162 | // settings 163 | theme: 'red', 164 | }) } 165 | } 166 | render() { 167 | returnMake Reactive Great Again! #MRGA #makereactivegreatagain pic.twitter.com/YMO2JEHdhd
— λ Calrissian (@mattpodwysocki) 8 aprile 2016