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
| @withRouter() | |
| class HomePage extends PureComponent<RouteComponentProps> { | |
| render() { | |
| return ( | |
| <a onClick={this.props.history.push("/catalog")}>Catalog</a> | |
| ); | |
| } | |
| } | |
| // now I wanna make a snapshot testing |
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
| export default function withLogger<T>( | |
| WrappedComponent: React.ComponentType<T> | |
| ): React.ComponentType<T> { | |
| const name = WrappedComponent.displayName || WrappedComponent.name; | |
| class InjectionWrapper extends React.Component<any, any> { | |
| static contextType = LoggerContext; | |
| static displayName = `withLogger(${name})`; | |
| static WrappedComponent = WrappedComponent; |
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
| <ErrorBoundary> | |
| <ApolloProvider client={apolloClient}> | |
| <Provider store={reduxStore}> | |
| <Router history={browserHistory}> | |
| <Translation> | |
| <CookiesProvider> | |
| ... | |
| ... | |
| ... | |
| <App /> |
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 App extends PureComponent { | |
| render() { | |
| const browserHistory = createBrowserHistory(); | |
| return ( | |
| <Router history={browserHistory}> | |
| <Switch> | |
| <Route path="/" component={HomePage} exact={true} /> | |
| </Switch> | |
| </Router> | |
| ); |
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
| import * as React from "react"; | |
| import { PureComponent } from "react"; | |
| interface IProps { | |
| label: string; | |
| doSomeMagic: () => void; | |
| } | |
| export default class Foo extends PureComponent<IProps> { | |
| render() { |
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
| defmodule App.EventDispatcher do | |
| use Rsed.EventDispatcher, name: :my_app_ed | |
| def configure() do | |
| %{} | |
| |> Rsed.ListenersBag.add_subscriber(App.Users.UserRegistrationSubscriber) | |
| |> Rsed.ListenersBag.add_listener(:user_sign_up, {App.Users.RegistrationEmail, :send_email}, 0) | |
| end | |
| end |
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
| defmodule Rsed.EventDispatcher do | |
| defmacro __using__(opts) do | |
| name = Keyword.get(opts, :name) | |
| quote do | |
| use GenServer | |
| # rest of our functions | |
| defp my_name() do | |
| unquote(name) |
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
| defmodule App.Application do | |
| use Application | |
| def start(_type, _args) do | |
| import Supervisor.Spec | |
| children = [ | |
| supervisor(App.Repo, []) | |
| supervisor(App.Web.Endpoint, []), | |
| worker(Rsed.EventDispatcher, []) # adds our event dispatcher |
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
| defmodule Rsed.Event do | |
| @enforce_keys [:name] | |
| defstruct [:name, :data] | |
| @type t :: %Rsed.Event{ | |
| name: String.t(), | |
| data: any(), | |
| } | |
| end |
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
| expected_listeners = %{ | |
| test_event_2: [ | |
| {Rsed.Test.TestSubscriber2, :handler_2, 0}, | |
| {Rsed.Test.TestSubscriber, :handler_2, 100} | |
| ], | |
| test_event_5: [{Rsed.Test.TestSubscriber, :handler_5, 100}], | |
| test_event_3: [{Rsed.Test.TestSubscriber2, :test_event_3_handler, 0}], | |
| test_event_4: [ | |
| {Rsed.Test.TestSubscriber2, :handler_5, 100}, | |
| {Rsed.Test.TestSubscriber2, :handler_6, 200} |