This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
const initialState = { movies: ['Mad Max'] }; | |
const store = createStore(reducer, initialState); | |
$: mMovies = $store.movies.filter((movie) => movie.includes('M')); | |
</script> | |
<div>{mMovies.join(', ')}, brought to you by the letter M</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
const reducer = (state, action) => { | |
switch(action.type) { | |
case 'add_movie': | |
return { ...state, movies: [...state.movies, action.id] }; | |
default: | |
return state; | |
} | |
}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { writable } from 'svelte/store'; | |
const createStore = (reducer, initialState) => { | |
const { subscribe, update } = writable(initialState); | |
const dispatch = (action) => update((state) => reducer(state, action)); | |
return { subscribe, dispatch }; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
export let movies; // <-- This is how Svelte defines a prop | |
const addBatman = () => { | |
movies = [...movies, 'Batman']; | |
}; | |
</script> | |
<div>{movies.join(', ')}</div> | |
<button on:click={addBatman}>Add Batman</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import { MoviePage, MovieBrowser } from './components'; | |
let movies = ['Blade Runner', 'Footloose']; | |
</script> | |
<MoviePage bind:movies /> | |
<MovieBrowser bind:movies /> | |
<MovieDetail bind:movies /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This will work | |
const reducer = (state, action) => { | |
if (action.type === CANCEL) { | |
return state; | |
} | |
switch (action.type) { | |
case FETCHING: | |
return {...state, text: 'Fetching...'}; | |
case SUCCESS: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){s=document.body.style;s.width='720px';s.margin='auto'})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name localhost; | |
# Reverse proxy | |
location /sentiment/ { | |
proxy_pass http://sa-web-app-lb:8080/; | |
} | |
location / { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: networking.k8s.io/v1beta1 | |
kind: Ingress | |
metadata: | |
name: sa-ingress | |
annotations: | |
nginx.ingress.kubernetes.io/ssl-redirect: 'false' | |
nginx.ingress.kubernetes.io/rewrite-target: / | |
spec: | |
rules: | |
- http: |