Step on me...
let handleBundleComplete = async () => {
//不知道什么意思...
handleBundleComplete = stats => !stats.stats[1].compilation.errors.length && runServer();
const server = await runServer();
const bs = browserSync.create();
bs.init({
...isDebug ? {} : { notify: false, ui: false },
proxy: {
target: server.host,
middleware: [wpMiddleware, hotMiddleware],
proxyOptions: {
xfwd: true,
},
},
}, resolve);
};
Don’t understand the meaning of this writing? Assign a value to the function itself within a function?
let handleBundleComplete = async () => {
handleBundleComplete = (...) => {...}
...
}
Assigning a value to the function itself within the function This situation will occur
For example, this function:
function oneAddTwo () {
let result = 1 + 2
oneAddTwo = function () {return result}
return result
}
As an actual application scenario, there is a function that determines what browser the current browser is. There is a bunch of judgment logic in this function. When it is executed for the first time, it is concluded that the current browser is Internet Explorer. Obviously, if you call this function a second time, there is no need to do it again. To execute that bunch of judgment logic, you only need to directly return ie. In this case, in this function, you can assign itself to another new function after the first execution. This new function can directly return ie.
handleBundleComplete is a variable
but this variable is initially assigned to a function.
Then when it is called, the variable is assigned to another function again.
Isn’t it just an assignment?