-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use stores in todo mvc kitchen sink (#261)
Resolves #254
- Loading branch information
Showing
15 changed files
with
239 additions
and
240 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Injector from '@dojo/widget-core/Injector'; | ||
import Store from '@dojo/stores/Store'; | ||
|
||
export default class StoreInjector extends Injector { | ||
constructor(payload: Store) { | ||
super(payload); | ||
payload.on('invalidate', () => { | ||
this.emit({ type: 'invalidate' }); | ||
}); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
19 changes: 15 additions & 4 deletions
19
todo-mvc-kitchensink/src/containers/ThemeSwitcherContainer.ts
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,12 +1,23 @@ | ||
import { Container } from '@dojo/widget-core/Container'; | ||
import Injector from '@dojo/widget-core/Injector'; | ||
import { switchLocale } from '@dojo/i18n/i18n'; | ||
|
||
import { TodoAppContext } from './../TodoAppContext'; | ||
import { ThemeSwitcher } from './../widgets/ThemeSwitcher'; | ||
import pirateThemeStyles from './../themes/pirate'; | ||
|
||
function getProperties(todoAppContext: TodoAppContext, properties: any) { | ||
function getProperties(themeContext: Injector) { | ||
return { | ||
changeTheme: todoAppContext.changeTheme.bind(todoAppContext) | ||
changeTheme(wantsPirate: boolean) { | ||
if (wantsPirate) { | ||
switchLocale('en-PR'); | ||
themeContext.set(pirateThemeStyles); | ||
} | ||
else { | ||
switchLocale('en'); | ||
themeContext.set(undefined); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
export const ThemeSwitcherContainer = Container(ThemeSwitcher, 'state', { getProperties }); | ||
export const ThemeSwitcherContainer = Container(ThemeSwitcher, 'theme-context', { getProperties }); |
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
16 changes: 11 additions & 5 deletions
16
todo-mvc-kitchensink/src/containers/TodoDetailsContainer.ts
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.