Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h1>Observables Example #2</h1>
<p>
  We have created 2 subscriptions where first
  <ul>
    <li>transform event into sum of offsets</li>
    <li>filter for those which are bigger than 200</li>
    <li>debounce by 300ms ( => subscribe called no more than once 300ms)</li>
    <li>log sum into subscribe</li>
  </ul>
  and second which just logs all events as they come.
</p>
<script src="https://unpkg.com/@reactivex/rxjs@5.0.3/dist/global/Rx.js"></script>

              
            
!

CSS

              
                
              
            
!

JS

              
                const source = Rx.Observable.fromEvent(document.body, 'mousemove');

// original example
source.subscribe(
      value => console.log(`val => x: ${value.offsetX} & y: ${value.offsetY}`),
      error => console.log(error),
      () => console.log('completed')
    );

// log event where sum of offsets is bigger than 200 and debounce by 300ms
source
  .map(value => value.offsetX + value.offsetY)
  .filter(offsetSum => offsetSum > 200)
  .debounceTime(300)
  .subscribe(
      value => console.log(`Offset sum once 300 ms => ${value}`),
      error => console.log(error),
      () => console.log('completed')
    );

              
            
!
999px

Console