Skip to content

Split INavigationAware into separate interfaces #25

@LeftTwixWand

Description

@LeftTwixWand

Now INavigationAware interface looks like this:

public interface INavigationAware
{
    void OnNavigatedTo(object parameter);

    void OnNavigatedFrom();
}

Current implementation is not correct from the architecture point of view. It forces us to have both methods, when one of them might be surplus.

public async void OnNavigatedTo(object parameter)
{
    if (parameter is long orderId)
    {
        // Do some stuff
    }
}

public void OnNavigatedFrom()
{
    // Useless
}

Like SOLID Interface Segregation Principle says: Clients should not be forced to implement any methods they don’t use
That's why it would be better to split INavigationAware into two separate interfaces INavigatedTo and INavigatedFrom.
And as a part of code enhancement, it might be possible to make a parameter in OnNavigatedTo(object parameter) strongly typed for the cases, where we have only one possible navigation scenario.

public interface INavigatedTo<T>
{
    void OnNavigatedTo(T parameter);
}

public interface INavigatedTo : INavigatedTo<object>
{
}

public interface INavigatedFrom
{
    void OnNavigatedFrom();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestlayer/applicationMeans some changes in the Application layer

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions