Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

React + Flux (Alt)

7,409 views

Published on

Como se encontra a web atualmente e suas necessidades. Exemplos de React e Flux com ES6.

Published in: Technology
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • accessibility Books Library allowing access to top content, including thousands of title from favorite author, plus the ability to read or download a huge selection of books for your pc or smartphone within minutes.........ACCESS WEBSITE Over for All Ebooks ..... (Unlimited) ......................................................................................................................... Download FULL PDF EBOOK here { http://bit.ly/2m6jJ5M } .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

React + Flux (Alt)

  1. 1. React? Já ouvi falar
  2. 2. Temas abordados 1. Problemas atuais da web 2. Onde a web está 3. Futuro? 4. Como o desenvolvimento é hoje 5. React 6. Flux
  3. 3. Cezar Luiz Programador Front-End JavaScript <3 Trabalha na Snowman Labs 23 anos
  4. 4. Web nos dias de hoje
  5. 5. Muita demanda de informação
  6. 6. Muita gente conectada
  7. 7. performance !important
  8. 8. Tempo de resposta deve ser cada vez menor
  9. 9. Onde a web está presente
  10. 10. Falando sobre front-end
  11. 11. Muito do que se faz hoje MVC Mineração de DOM - getElementById, etc Adiciona classe, retira classe Problemas de compatibilidade Dificuldade em escalar e aceitar grande quantidade de dados
  12. 12. Problemas com MVC
  13. 13. “MVC got really complicated really quickly”
  14. 14. !
  15. 15. Virtual DOM React abstracts away the DOM from you, giving a simpler programming model and better performance. React can also render on the server using Node, and it can power native apps using React Native.
  16. 16. Data Flow React implements one-way reactive data flow which reduces boilerplate and is easier to reason about than traditional data binding.
  17. 17. !framework
  18. 18. Por que não pensar mais na sua aplicação, na lógica, do que ficar se preocupando com o “DOM”?
  19. 19. import React from 'react'; import ReactDOM from 'react-dom'; class HelloWorld extends React.Component { render() { return <div>Hello World!</div> } } ReactDOM.render(<HelloWorld />, mountNode); JSX
  20. 20. import React from 'react'; import ReactDOM from 'react-dom'; class HelloWorld extends React.Component { render() { return React.createElement( "div", null, "Hello World" ); } } ReactDOM.render(React.createElement(HelloWorld), mountNode); JS compilado
  21. 21. state e PROPS Onde gerenciamos os dados da nossa aplicação
  22. 22. import MailHeader from './MailHeaderComponent'; import MailButtons from './MailButtonsComponent'; import MailsTable from './MailTablesComponent'; class Mails extends React.Component { render() { return ( <div className="mails-container"> <MailHeader /> <MailButtons /> <MailsTable /> </div> ); } }
  23. 23. import HeaderTitle from './header/HeaderTitleComponent'; import HeaderSearch from './header/HeaderSearchComponent'; import Profile from './ProfileComponent'; class MailHeader extends React.Component { render() { return ( <header className="mail-header"> <HeaderTitle title="Inbox" /> <HeaderSearch placeholder="Search..." /> <Profile user={user} /> </header> ); } }
  24. 24. import MailRow from './MailRowComponent'; class MailTable extends React.Component { constructor(props) { super(props); this.state = { loading: false, mails: [] }; } componentDidMount() { this.setState({ loading: true }); $.ajax({ url: `${host}/mails` }) .done((response) => { this.setState({ mails: response.results }); }) .complete(() => { this.setState({ loading: false }); }); } render() { if (this.state.loading) { return <p>Carregando emails...</p> } if (!this.state.mails.length) { return <p>Nenhum email por enquanto.</p> } return ( <table className="mails-table"> <thead>...</thead> <tbody> {this.state.mails.map((mail) => { return <MailRow mail={mail} /> })} </tbody> </table> ); } }
  25. 25. import MailRow from './MailRowComponent'; import $ from 'jquery'; class MailTable extends React.Component { constructor(props) { super(props); this.state = { loading: false, mails: [] }; } ... }
  26. 26. import MailRow from './MailRowComponent'; import $ from 'jquery'; class MailTable extends React.Component { ... componentDidMount() { this.setState({ loading: true }); $.ajax({ url: `${host}/mails` }) .done((response) => { this.setState({ mails: response.results }); }) .complete(() => { this.setState({ loading: false }); }); } ... }
  27. 27. import MailRow from './MailRowComponent'; class MailTable extends React.Component { ... render() { if (this.state.loading) { return <p>Carregando emails...</p> } if (!this.state.mails.length) { return <p>Nenhum email por enquanto.</p> } return ( <table className="mails-table"> <thead>...</thead> <tbody> {this.state.mails.map((mail) => { return <MailRow mail={mail} /> })} </tbody> </table> ); } }
  28. 28. class MailRow extends React.Component { changeCheck() { let checkbox = this.refs.checkbox; let dom = React.findDOMNode(checkbox); // Não é tão necessário let { value, name, type } = checkbox; ... } render() { return ( <tr> <td> <input onChange={this.changeCheck.bind(this)} type="checkbox" name="checkMail" ref="checkbox" /> </td> <td>{this.props.name}</td> <td>{this.props.resume}</td> <td>{this.props.date}</td> </tr> ); } }
  29. 29. c o m p o n e n t i z a ç ã o
  30. 30. ciclo de vida
  31. 31. 3 partes principais Mounting - Um componente irá ser inserido no DOM. Updating - Um componente está a ser re-renderizado para determinar se o DOM deverá ser atualizado. (Virtual DOM) Unmounting - Um componente está sendo removido do DOM. Além disso, o React fornece métodos de ciclos de vida para você interceptar esse processo. Métodos do tipo “will”.
  32. 32. Mounting - 3 métodos getInitialState - Chamado antes de um componente ser montado. Componentes que usam state devem implementar isso para retornar dados iniciais. componentWillMount - Chamado imediatamente antes de ocorrer a montagem. componentDidMount - Chamado imediatamente depois de ocorrer a montagem. Se precisar alterar o DOM, deve vir aqui.
  33. 33. Updating - 4 métodos componentWillReceiveProps(object nextProps) - Chamado quando um componente recebe novas propriedades. shouldComponentUpdate(object nextProps, object nextState) Deve retornar um boolean se o componente deverá ser atualizado ou não. componentWillUpdate(object nextProps, object nextState) Chamado imediatamente antes de uma atualização acontecer. Não pode chamar this.setState aqui. componentDidUpdate(object prevProps, object prevState) Chamado imediatamente depois da atualização acontecer.
  34. 34. Unmounting - 1 método componentWillUnmount - Chamado imediatamente antes de um componente ser desmontado e destruído. Limpezas devem ser feitas aqui.
  35. 35. state props refs render ciclos de vida componentização JSX e JS compilado UI complexas event system (onClick onChange...) ajax isso é React
  36. 36. E o tal do flux?
  37. 37. !framework
  38. 38. Arquitetura de aplicação para construir interfaces
  39. 39. “simplificar”
  40. 40. exemplos com altjs
  41. 41. // dispatcher.js import alt from 'alt'; let alt = new Alt(); export default alt;
  42. 42. // actions/MailActions.js import alt from '../dispatcher'; import $ from 'jquery'; class MailActions { getMails() { $.ajax({ url: `${host}/mails` }) .done((res) => { this.actions.getMailsSuccess(res); }) .fail(() => { this.actions.getMailsFail(); }); return true; } getMailsSuccess(res) { return res; } getMailsFail() { // Envia uma notificação de erro para o usuário na tela return false; } } export default alt.createActions(MailActions);
  43. 43. // stores/MailStore.js import alt from '../dispatcher'; import MailActions from '../actions/MailActions'; class MailStore { constructor() { this.state = { loading: false, error: false, mails: [] }; this.bindActions(MailActions); } onGetMails() { this.setState({ loading: true, error: false }); } onGetMailsSuccess(response) { this.setState({ loading: false, mails: response.result }); } onGetMailsFail(err) { this.setState({ loading: false, error: err, mails: [] }); } } export default alt.createStore(MailStore, 'MailStore');
  44. 44. // components/MailTableComponent.js import MailRow from './MailRowComponent'; import MailActions from '../actions/MailActions'; import MailStore from '../stores/MailStore'; class MailTable extends React.Component { constructor(props) { super(props); this.state = MailStore.getState(); this.onMailChange = this.onMailChange.bind(this); } componentDidMount() { MailStore.listen(this.onMailChange); MailActions.getMails(); } componentWillUnmount() { MailStore.unlisten(this.onMailChange); } onMailChange(state) { this.setState(state); } render() { if (this.state.loading) { return <p>Carregando emails...</p> } if (!this.state.mails.length) { return <p>Nenhum email por enquanto.</p> } return ( <table className="mails-table"> <thead>...</thead> <tbody> {this.state.mails.map((mail) => { return <MailRow mail={mail} /> })} </tbody> </table> ); } }
  45. 45. // components/MailTableComponent.js import MailRow from './MailRowComponent'; import MailActions from '../actions/MailActions'; import MailStore from '../stores/MailStore'; class MailTable extends React.Component { constructor(props) { super(props); this.state = MailStore.getState(); this.onMailChange = this.onMailChange.bind(this); } ... }
  46. 46. // components/MailTableComponent.js import MailRow from './MailRowComponent'; import MailActions from '../actions/MailActions'; import MailStore from '../stores/MailStore'; class MailTable extends React.Component { ... componentDidMount() { MailStore.listen(this.onMailChange); MailActions.getMails(); } componentWillUnmount() { MailStore.unlisten(this.onMailChange); } onMailChange(state) { this.setState(state); } ... }
  47. 47. // components/MailTableComponent.js import MailRow from './MailRowComponent'; import MailActions from '../actions/MailActions'; import MailStore from '../stores/MailStore'; class MailTable extends React.Component { ... render() { if (this.state.loading) { return <p>Carregando emails...</p> } if (!this.state.mails.length) { return <p>Nenhum email por enquanto.</p> } return ( <table className="mails-table"> <thead>...</thead> <tbody> {this.state.mails.map((mail) => { return <MailRow mail={mail} /> })} </tbody> </table> ); } }
  48. 48. “simplificar”
  49. 49. O que ele pode fazer por nós alta escalabilidade fácil manutenção isomorfismo native apps com react-native programação reativa
  50. 50. Quem já usa airbnb netflix yahoo asana atlassian coursera bbc deezer dropbox facebook instagram imdb imgur marvelapp periscope reddit salesforce uber whatsapp globoplay
  51. 51. (brinks)
  52. 52. Obrigado! { github: “CezarLuiz0”, twitter: “cezar_luiz”, email: “cezarluiz.c@gmail.com” }

×