Backbone JS – A Javascript MV* Framework – Backbone JS



Backbone JS – A Javascript MV* Framework – Backbone JS

0 0


presentation-intro-to-backbone

Intro to Backbone Presentation

On Github summanerd / presentation-intro-to-backbone

Backbone JS

A Javascript MV* Framework

Created by Mauricia Ragland / @summanerd

What We Will Discuss

What Backbone JS is Why You Should Use It How To Use It

Backbone JS

A Javascript library that interacts with a REST Api built upon a MVC architecture that provides a pre-defined pattern and tools that helps javascript code become more organized and reusable.

REST API

This feature has been built into Backbone via Models and Collections.

Basement Level 2

Cornify

Why You Should Use It

  • Limits Spaghetti Code
  • Naturally Organizes
  • Easier to Maintain in a team environment
  • You're not maintaining core code
  • Easily Extensible
  • Allows you to implement the DRY priniciple
  • Allows you to create testable code

How To Use Backbone

Be sure to have the following Dependencies

  • Underscore JS - Highly recommended Utility Library
  • Json2.js
  • JQuery/Zepto

Models

In programming terms this usually represents a class and is usually a front-end version of the model from your backend MVC framework or resource of REST API

  • This is the data the will be manipulated and validated on the screen via user interaction
  • The data is retrieved via a url created by backbone that is designed to work with a REST API, but can be configured to work without a REST Api

Collection

An array of Models with powerful enumeration functions (provided by Underscore JS) that include filtering, mapping, reducing, and much more

View

Corresponds to portions of the UI and handles how a model interacts with it

Events

Makes a lot of the magic happen. It allows several views to work together as if they were one. This is one of the major reason views do not have to be tightly coupled. An event in one view can trigger an action in another.

Routes

Replaces the previously used hash fragment (http://www.url.com/#page) with real routes like http://www.url.com/page

Sync

Responsible for reading and updating models with the server. It uses an ajax request to a REST Api that uses JSON data.

GET Request – to Read/Retrieve Model POST Request – to create new model PUT Request – to Update Model DELETE Request – to Delete Model

This can be customized per model or globally to use the persistant storage of your choice

Resources

Fantastic Ordered List

One is smaller than... Two is smaller than... Three!

Markdown support

For those of you who like that sort of thing. Instructions and a bit more info available here.

<section data-markdown>
  ## Markdown support

  For those of you who like that sort of thing.
  Instructions and a bit more info available [here](https://github.com/hakimel/reveal.js#markdown).
</section>

Transition Styles

You can select from different transitions, like: Cube - Page - Concave - Zoom - Linear - None - Default

Themes

Reveal.js comes with a few themes built in: Sky - Beige - Simple - Serif - Night - Default

* Theme demos are loaded after the presentation which leads to flicker. In production you should load your theme in the <head> using a <link>.

Global State

Set data-state="something" on a slide and "something" will be added as a class to the document element when the slide is open. This lets you apply broader style changes, like switching the background.

"blackout"

"soothe"

Custom Events

Additionally custom events can be triggered on a per slide basis by binding to the data-state name.

Reveal.addEventListener( 'customevent', function() {
	console.log( '"customevent" has fired' );
} );
					

Clever Quotes

These guys come in two forms, inline: The nice thing about standards is that there are so many to choose from and block:

For years there has been a theory that millions of monkeys typing at random on millions of typewriters would reproduce the entire works of Shakespeare. The Internet has proven this theory to be untrue.

Pretty Code

function linkify( selector ) {
  if( supports3DTransforms ) {

    var nodes = document.querySelectorAll( selector );

    for( var i = 0, len = nodes.length; i < len; i++ ) {
      var node = nodes[i];

      if( !node.className ) ) {
        node.className += ' roll';
      }
    };
  }
}
					

Courtesy of highlight.js.

Intergalactic Interconnections

You can link between slides internally, like this.

Fragmented Views

Hit the next arrow...

... to step through ...

any type of view fragments This slide has fragments which are also stepped through in the notes window.

Fragment Styles

There's a few styles of fragments, like:

grow

shrink

roll-in

fade-out

highlight-red

highlight-green

highlight-blue

Spectacular image!

Export to PDF

Presentations can be exported to PDF, below is an example that's been uploaded to SlideShare.

Take a Moment

Press b or period on your keyboard to enter the 'paused' mode. This mode is helpful when you want to take disctracting slides off the screen during a presentation.

Stellar Links

It's free

reveal.js and rvl.io are entirely free but if you'd like to support the projects you can donate below. Donations will go towards hosting and domain costs.

THE END

BY Hakim El Hattab / hakim.se