Giter VIP home page Giter VIP logo

fewpjs-stitching-together-the-three-pillars-new's Introduction

Stitching Together the Three Pillars

Learning Goals

  • Identify the three essential pillars of front-end web programming
  • Cause a change to given code so that DOM updating effect is seen
  • Cause a change to given code so that server-side behavior is stubbed in
  • Cause a change to given code so that event listening has an effect

Introduction

Knowing what web programming is and how its elements work together conceptually is an essential first step, but in order to help orient our upcoming lessons, let's see it in action. In this lesson we've provided you a simple social media application called "Simple Liker." You'll see several posts which can be "liked" by clicking on the heart...well, they could be if the critical code hadn't been commented out. This lesson will guide you in uncommenting the critical code so that you restore the "like" functionality. In subsequent lessons, you'll learn the skills needed to create the pieces that you'll stitch together in this lesson.

Although this code-along is structured as a lab, you don't need to do anything to get the tests passing. In fact, if you run the one test, you should see that it's already passing. Instead, you just need to follow along with the instructions and pay attention to how the different parts of the code are working together to create the desired functionality.

Identify the Three Essential Pillars of Front-End Web Programming

We've introduced our three essential pillars of front-end web programming:

  • Manipulating the Document Object Model (DOM)
  • Recognizing JS events
  • Communicating with the server

We also described the interaction that we want to make: "favoriting" an item on social media to turn an empty heart to red. Now, let's pull it all together and see how it works by walking through some code.

Cause a Change to Given Code So That DOM Updating Effect Is Seen

Meet our app, Simple Liker! It demos the favoriting action we've talked about and alerts you to what is happening at each step of the process. When all is working as it should, the action looks like this:

working example of favoriting a post

Go ahead and open up index.html in your browser. To do this, make sure you're in the directory where this README lives in your terminal. If you're on a Mac, run open index.html and if you're using Windows, run explorer.exe index.html. If that doesn't work, you can open the file directly from Chrome. Choose Open file... from the File menu, navigate to the directory where this README is located, and open the file.

Your experience will look something like this:

non-working example of favoriting a post

... which is, nothing happens. That's because we haven't switched on the working code yet. We're going to go through, step by step, find the code that makes each step work, and demo it to see how it looks in the browser.

Open up your demo.js file and take a look at everything there. Find the comments that begin with "Step 1." Follow the instructions there to un-comment the code that locates the page element we want โ€” in this case, the heart.

demonstration of un-commenting step one

Cause a Change to Given Code So That Server-Side Behavior Is Stubbed in

Next, in your demo.js file, find the comments describing Step 2, which sets up the mock server communication (our third pillar):

demonstration of un-commenting step two

Cause a Change to Given Code So That Event Listening Has an Effect

Now, find Step 3 in the commented code. It's time to bring in the second pillar, events:

demonstration of un-commenting step three

We've activated all the parts of our code that stitch in the three pillars of front-end web programming. Let's go back to your browser and see what Simple Liker looks like in action.

working example of favoriting a post

Conclusion

We're starting to see how the pieces work together now! Now we're ready to dive into the individual pillars and learn more about how each one functions. First, we take on manipulating the DOM.

fewpjs-stitching-together-the-three-pillars-new's People

Contributors

aspenjames avatar dependabot[bot] avatar graciemcguire avatar ihollander avatar jenmyers avatar lizbur10 avatar maxwellbenton avatar micahshute avatar sdboahen avatar sgharms avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fewpjs-stitching-together-the-three-pillars-new's Issues

can't run learn test or learn submit

this lab has an issue which says Traceback (most recent call last):
11: from /usr/local/rvm/gems/ruby-2.6.1/bin/ruby_executable_hooks:24:in<main>' 10: from /usr/local/rvm/gems/ruby-2.6.1/bin/ruby_executable_hooks:24:ineval'
9: from /usr/local/rvm/gems/ruby-2.6.1/bin/learn-test:23:in <main>' 8: from /usr/local/rvm/gems/ruby-2.6.1/bin/learn-test:23:in load'
7: from /usr/local/rvm/gems/ruby-2.6.1/gems/learn-test-2.6.1/bin/learn-test:68:in <top (required)>' 6: from /usr/local/rvm/gems/ruby-2.6.1/gems/learn-test-2.6.1/lib/learn_test/runner.rb:20:in run'
5: from /usr/local/rvm/gems/ruby-2.6.1/gems/learn-test-2.6.1/lib/learn_test/runner.rb:20:in fork' 4: from /usr/local/rvm/gems/ruby-2.6.1/gems/learn-test-2.6.1/lib/learn_test/runner.rb:21:in block in run'
3: from /usr/local/rvm/gems/ruby-2.6.1/gems/learn-test-2.6.1/lib/learn_test/runner.rb:44:in report_and_clean' 2: from /usr/local/rvm/gems/ruby-2.6.1/gems/learn-test-2.6.1/lib/learn_test/reporter.rb:13:in report'
1: from /usr/local/rvm/gems/ruby-2.6.1/gems/learn-test-2.6.1/lib/learn_test/reporter.rb:47:in report' /usr/local/rvm/gems/ruby-2.6.1/gems/learn-test-2.6.1/lib/learn_test/strategies/mocha.rb:42:in results': undefined method `[]' for nil:NilClass (NoMethodError)

Non-working README LAB

I worked with an AAQ coach and they agreed this was not working. All of the code was already uncommented and trying to submit through learn submit repeatedly failed.

I am running Windows 10 WSL 2.

Odd Errors won't pass test

  1. "after all" hook in "{root}"

/Users/cedricjoaquin/.rvm/gems/ruby-2.6.1/gems/learn-test-2.6.1/lib/learn_test/strategies/mocha.rb:42:in results': undefined method []' for nil:NilClass (NoMethodError)

We've commented out the tests in test/indexTest.js and we still get the error shown above. Had to just move on with test not passing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.