This one catches errors not only during the ajax request, but during the
onSuccess
handler execution.
const response = ajax(options).then(onSuccess).catch(onFailure)
The appropriate translation to async/await could be something like this:
function debugFocus(turnOn) { | |
if (turnOn && window.debugFocusInterval) { | |
console.log("debugFocus: already on"); | |
return; | |
} | |
if (!turnOn && !window.debugFocusInterval) { | |
console.log("debugFocus: already off"); | |
return; | |
} |
#!/bin/bash | |
# git-cleanup-repo | |
# | |
# Author: Rob Miller <rob@bigfish.co.uk> | |
# Adapted from the original by Yorick Sijsling | |
git checkout master &> /dev/null | |
# Make sure we're working with the most up-to-date version of master. | |
git fetch |
/** | |
* Converts a given object to a jsonapi-compliant version of it, suitable to be used in api calls | |
* | |
* Specifying relationship attributes | |
* | |
* Each property in the `relationshipAttrs` argument correspondes to an attribute name in `object`. | |
* The value should be either a string or a small object specifying `name` (optional) and `type`. | |
* | |
* If the value is a string, this is used both for the name of the relationship in the resulting | |
* payload object, and for the type of the objects related. However, if the value of a |
#!/bin/sh | |
### | |
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer) | |
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos | |
### | |
# Alot of these configs have been taken from the various places | |
# on the web, most from here | |
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx |
Append the following to the end of this file:
/Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js
document.addEventListener('DOMContentLoaded', function() {
$.ajax({
url: 'https://cdn.rawgit.com/laCour/slack-night-mode/master/css/raw/black.css',
success: function(css) {
$("").appendTo('head').html(css);
import React, { Component } from ‘react’; | |
const noop = () => {}; | |
export default class MyComponent extends Component { | |
state = { data: null, error: null }; | |
handleSuccess = data => { | |
this.setState({ data }); | |
}; |
I hereby claim:
To claim this, I am signing this object:
// Regarding these discussions about Scala class constructor parameters: | |
// http://stackoverflow.com/questions/15639078/scala-class-constructor-parameters | |
// http://stackoverflow.com/questions/1889454/in-scala-how-do-you-define-a-local-parameter-in-the-primary-constructor-of-a-cl | |
// Class parameter `fake` is not prefixed by either `val` or `var` | |
class Testing(fake: Boolean) { | |
val buffer = if (fake) null else new StringBuilder() | |
def output(str: Any): Unit = { | |
// The class parameter `fake` is accessible beyond the construction phase |
gem 'browserify-rails', '1.5.0' # until fix: https://github.com/browserify-rails/browserify-rails/issues/101
gem 'react-rails'
Browserify-rails allows to use browserify within assets pipeline. React-rails is here only to allow to use #react_component
(and thus, prerendering).
Note that jquery-rails
can be removed from Gemfile, the npm version of jquery
and jquery-ujs
will be used instead.