This file contains hidden or 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
function log(func) { | |
return function() { | |
func() | |
console.log('Function called') | |
} | |
} | |
function getData() { ... } | |
getData = log(getData) |
This file contains hidden or 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
// register global handler | |
catchDecorator.register((error) => Toast.error(error.message)) | |
@Component | |
class LoginPage extends Vue { | |
// ... | |
// catch errors and run global handler | |
@Catch() | |
async loginUser() { | |
const token = await api.loginUser(this.email, this.password) |
This file contains hidden or 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
class Main { | |
public static void main(String[] args) throws IOException { | |
FileReader file = new FileReader("C:\\test\\a.txt"); | |
// ... | |
} | |
} |
This file contains hidden or 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
@Component | |
class App extends Vue { | |
// ... | |
decodeData(data) { | |
try { | |
this.decodedData = atob(data) // can throw DOMException | |
} catch(error) { | |
Toast.error(error.message) | |
} | |
} |
This file contains hidden or 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
// main.js | |
Vue.config.errorHandler = function (error) { | |
Toast.error(error.message) | |
console.warn(error.message) | |
} | |
// App.vue | |
@Component | |
export default class App extends Vue { | |
async created() { |
This file contains hidden or 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
@Component | |
class LoginPage extends Vue { | |
// ... | |
async loginUser() { | |
try { | |
const token = await api.loginUser(this.email, this.password) | |
handleLogin(token) | |
} catch(error) { | |
Toast.error(error.message) | |
} |
This file contains hidden or 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
@Component | |
class LoginPage extends Vue { | |
// ... | |
async loginUser() { | |
try { | |
const token = await api.loginUser(this.email, this.password) | |
handleLogin(token) | |
} catch(error) { | |
Toast.error(error.message) | |
} |
This file contains hidden or 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
@Component | |
class LoginPage extends Vue { | |
// ... | |
loginUser() { | |
api.loginUser(this.email, this.password) | |
.then(handleLogin) | |
.catch(error => Toast.error(error.message)) | |
} | |
} |
This file contains hidden or 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
const i = 'gfudi'; | |
const k = s => s.split('').map(c => String.fromCharCode(c.charCodeAt() - 1)).join(''); | |
self[k(i)](urlWithYourPreciousData); |
This file contains hidden or 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
// Listen for changes | |
componentDidMount() { | |
ListStore.on('change', this._onChange); | |
} | |
// Update view state when change event is received | |
_onChange: function() { | |
this.setState(ListStore.getState()); | |
} |