Skip to content

Instantly share code, notes, and snippets.

@vuejsdevelopers
vuejsdevelopers / index.html
Last active February 6, 2019 23:35
New in Vue: ES Module Browser Build - Snippet 02
<script type="module">
import {addTextToBody} from './utils.mjs';
addTextToBody('Modules are pretty cool.');
</script>
@vuejsdevelopers
vuejsdevelopers / utils.mjs
Last active February 6, 2019 23:34
New in Vue: ES Module Browser Build - Snippet 03
export function addTextToBody(text) {
const div = document.createElement('div');
div.textContent = text;
document.body.appendChild(div);
}
@vuejsdevelopers
vuejsdevelopers / index.html
Created February 6, 2019 23:32
New in Vue: ES Module Browser Build - Snippet 01
<script type="module">
import Vue from 'https://unpkg.com/vue@2.6.0/dist/vue.esm.browser.min.js';
new Vue({
...
});
</script>
@vuejsdevelopers
vuejsdevelopers / app.vue
Created January 23, 2019 15:17
What the Tick is Vue.nextTick? - Snippet 03
async mounted () {
this.message = 'updated'
console.log(this.$el.textContent) // 'not updated'
await this.$nextTick()
console.log(this.$el.textContent) // 'updated'
}
@vuejsdevelopers
vuejsdevelopers / app.vue
Last active January 23, 2019 15:17
What the Tick is Vue.nextTick? - Snippet 01
Vue.nextTick(function () {
// do something cool
})
@vuejsdevelopers
vuejsdevelopers / app.vue
Created January 23, 2019 15:16
What the Tick is Vue.nextTick? - Snippet 02
mounted() {
this.$nextTick(() => {
// The whole view is rendered, so I can safely access or query
// the DOM. ¯\_(ツ)_/¯
})
}
@vuejsdevelopers
vuejsdevelopers / AppServiceProvider.php
Created January 8, 2019 18:31
Bad UX in Web Apps that Perform Intensive Tasks (and How to Avoid it with Queues) - Snippet 08
Queue::after(function (JobProcessed $event) {
$result = ... // get the job result from the DB
SendEmail::dispatch($event->data["email"], $result);
});
@vuejsdevelopers
vuejsdevelopers / script.js
Created January 8, 2019 18:30
Bad UX in Web Apps that Perform Intensive Tasks (and How to Avoid it with Queues) - Snippet 07
public function store(Request $request)
{
if ($request->hasFile('csv')) {
ProcessCSV::dispatch($request->file("csv"), $request->email);
return response("File received for processing!", 202);
} else {
return response("No file provided.", 400);
}
}
@vuejsdevelopers
vuejsdevelopers / index.html
Created January 8, 2019 18:30
Bad UX in Web Apps that Perform Intensive Tasks (and How to Avoid it with Queues) - Snippet 06
<form id="upload" enctype="multipart/form-data" @submit.prevent="submit">
<p>Please select the file you'd like to upload. Provide an email address and we'll inform you of the result and spam you later.</p>
<input type="file" name="csv" />
<input type="email" name="email" />
<input type="submit" value="Upload" />
</form>
@vuejsdevelopers
vuejsdevelopers / CSVUploadController.php
Created January 8, 2019 18:29
Bad UX in Web Apps that Perform Intensive Tasks (and How to Avoid it with Queues) - Snippet 05
public function store(Request $request)
{
if ($request->hasFile('csv')) {
ProcessCSV::dispatch($request->file("csv"));
return response("File received for processing!", 202);
} else {
return response("No file provided.", 400);
}
}