Skip to content

Instantly share code, notes, and snippets.

View gufranmirza's full-sized avatar

Gufran Mirza gufranmirza

View GitHub Profile
package main
import (
"fmt"
"time"
)
func main() {
fmt.Println("main execution started")
package main
import (
"fmt"
"time"
)
func numbers() {
for i := 1; i <= 5; i++ {
time.Sleep(250 * time.Millisecond)
package main
import (
"fmt"
"time"
)
func printHello() {
time.Sleep(time.Millisecond)
fmt.Println("Hello World!")
package main
import (
"fmt"
"time"
)
func printHello() {
fmt.Println("Hello World!")
}
package main
import "fmt"
func printHello() {
fmt.Println("Hello World!")
}
func main() {
fmt.Println("main execution started")
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
function lazyLoad(view){
return() => import(`@/views/${view}.vue`)
}
export default new Router({
mode: 'history',
base: process.env.BASE_URL,
routes: [
export default new Router({
routes: [
{
path: '/',
name: 'home',
component: Home
},
{
path: '/about',
name: 'about',
import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'
import About from './views/About.vue'
Vue.use(Router)
export default new Router({
routes: [
{
path: '/',
name: 'home',
// pages/products/_id.vue
export default {
asyncData(context) {
return axios.get(`https://my-api-server/api/products/${params.id}, (response) => {
return { product: response.data };
});
}
...
}
// pages/products/_id.vue
export default {
fetch(({ store, params }) {
if (typeof (store.state.products.byId[params.id]) === 'undefined') {
return store.dispatch('products/loadProduct', {id: params.id});
}
}
...
}