-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
2,757 additions
and
422 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,152 @@ | ||
export const LogMiddleware = function() { | ||
this.mwtype = 'router'; | ||
this.features = ['params', 'query']; | ||
export const AppMiddlewarePre = function() { | ||
this.mwtype = 'app'; | ||
|
||
this.before = function(app) { | ||
log('[AppMiddlewarePre] before called', 'red'); | ||
}; | ||
|
||
this.after = function(app) { | ||
log('[AppMiddlewarePre] after called', 'red'); | ||
|
||
app.setStates({ test: 'test' }); | ||
}; | ||
}; | ||
|
||
export const AppMiddleware = function(test) { | ||
this.mwtype = 'app'; | ||
|
||
if (test !== 'test') throw new Error('AppMiddleware 인자 에러'); | ||
|
||
this.before = function(app, next) { | ||
log('[AppMiddleware] before called', 'red'); | ||
|
||
if (typeof app !== 'object' || typeof next !== 'function') throw new Error('AppMiddleware before 인자 에러'); | ||
if (Backbone.History.started) throw new Error('AppMiddleware before 발동 시점 에러'); | ||
|
||
const state = app.getStates('test'); | ||
|
||
if (state !== 'test') throw new Error('AppMiddleware before app 인자 에러'); | ||
|
||
app.beforeTested = false; | ||
|
||
setTimeout(function() { | ||
app.beforeTested = true; | ||
|
||
next(); | ||
}, 1000); | ||
}; | ||
|
||
this.after = function(app, next) { | ||
log('[AppMiddleware] after called', 'red'); | ||
|
||
this.before = function(feature) { | ||
console.log('router middleware'); | ||
if (typeof app !== 'object' || typeof next !== 'function') throw new Error('AppMiddleware after 인자 에러'); | ||
if (!app.beforeTested) throw new Error('AppMiddleware after 발동 시점 에러'); | ||
|
||
next(); | ||
}; | ||
}; | ||
|
||
export const DebugMiddleware = function() { | ||
export const ViewMiddleware = function(test) { | ||
this.mwtype = 'view'; | ||
this.features = []; | ||
|
||
this.after = function(view, dom) { | ||
console.log('view middleware'); | ||
if (test !== 'test') throw new Error('ViewMiddleware 인자 에러'); | ||
|
||
this.before = function(view, next) { | ||
log('[ViewMiddleware] before called', 'orange'); | ||
|
||
if (typeof view !== 'object' || typeof next !== 'function') throw new Error('ViewMiddleware before 인자 에러'); | ||
|
||
next(); | ||
}; | ||
|
||
this.after = function(view, next) { | ||
log('[ViewMiddleware] after called', 'orange'); | ||
|
||
if (typeof view !== 'object' || typeof next !== 'function') throw new Error('ViewMiddleware after 인자 에러'); | ||
if (view.$el.html() === '') throw new Error('ViewMiddleware after 발동 시점 에러'); | ||
|
||
view.$el.append('<p>ViewMiddleware add this text.</p>'); | ||
next(); | ||
}; | ||
|
||
this.unmount = function(view, next) { | ||
log('[ViewMiddleware] unmount called', 'orange'); | ||
|
||
if (typeof view !== 'object' || typeof next !== 'function') throw new Error('ViewMiddleware unmout 인자 에러'); | ||
if (view.$el.html() === '') throw new Error('ViewMiddleware unmount 발동 시점 에러'); | ||
|
||
setTimeout(function() { | ||
if (!view || view.$el.html() === '') throw new Error('ViewMiddleware unmount 발동 시점 에러'); | ||
|
||
next(); | ||
}, 1000); | ||
}; | ||
}; | ||
|
||
export const TimeoutMiddleware = function() { | ||
export const ReducerMiddlewarePre = function() { | ||
this.mwtype = 'reducer'; | ||
this.features = ['timeout']; | ||
|
||
this.before = function(feature) { | ||
feature.timeout = 10000; | ||
this.before = function(settings) { | ||
log('[ReducerMiddlewarePre] before called', 'blue'); | ||
|
||
settings.timeout = 5000000; | ||
}; | ||
}; | ||
|
||
export const ReducerMiddleware = function(test) { | ||
this.mwtype = 'reducer'; | ||
|
||
if (test !== 'test') throw new Error('ReducerMiddleware 인자 에러'); | ||
|
||
this.before = function(settings, app, next) { | ||
log('[ReducerMiddleware] before called', 'blue'); | ||
|
||
if (typeof app !== 'object' || typeof next !== 'function') throw new Error('ReducerMiddleware before 인자 에러'); | ||
if (settings.timeout !== 5000000) throw new Error('ReducerMiddleware before 인자 에러'); | ||
|
||
next(); | ||
}; | ||
|
||
this.after = function(app, next) { | ||
log('[ReducerMiddleware] after called', 'blue'); | ||
|
||
if (typeof app !== 'object' || typeof next !== 'function') throw new Error('ReducerMiddleware after 인자 에러'); | ||
|
||
next(); | ||
}; | ||
}; | ||
|
||
export const RouterMiddlewarePre = function() { | ||
this.mwtype = 'router'; | ||
|
||
this.before = function(route, app) { | ||
log('[RouterMiddlewarePre] before called', 'green'); | ||
}; | ||
|
||
this.after = function(route, app) { | ||
log('[RouterMiddlewarePre] after called', 'green'); | ||
}; | ||
}; | ||
|
||
export const RouterMiddleware = function(test) { | ||
this.mwtype = 'router'; | ||
|
||
if (test !== 'test') throw new Error('RouterMiddleware 인자 에러'); | ||
|
||
this.before = function(route, app, next) { | ||
log('[RouterMiddleware] before called', 'green'); | ||
|
||
if (typeof app !== 'object' || typeof next !== 'function') throw new Error('RouterMiddleware before 인자 에러'); | ||
if (route.url === 'layout1' && route.routeData.route !== 'good') throw new Error('RouterMiddleware before 인자 에러'); | ||
|
||
next(); | ||
}; | ||
|
||
this.after = function(route, app, next) { | ||
log('[RouterMiddleware] after called', 'green'); | ||
|
||
if (typeof app !== 'object' || typeof next !== 'function') throw new Error('RouterMiddleware after 인자 에러'); | ||
|
||
next(); | ||
}; | ||
}; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 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 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
Oops, something went wrong.