Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to refresh realtime data #25

Closed
5 tasks done
Katsute opened this issue Feb 28, 2022 · 5 comments · Fixed by #34
Closed
5 tasks done

Add method to refresh realtime data #25

Katsute opened this issue Feb 28, 2022 · 5 comments · Fixed by #34
Assignees
Labels
feature request mta-bus Bus related issues and features mta-lirr Long Island Railroad related issues and features mta-mnr Metro North Railroad related issues and features mta-subway Subway related issues and features
Milestone

Comments

@Katsute
Copy link
Member

Katsute commented Feb 28, 2022

Prerequisites

  • I have checked that no other similar feature request already exists.
  • I have checked discussions.
  • This feature request makes sense for the project.
  • I have checked that this feature does not already exist.
  • I am running the latest release version.

Feature

Add a new method .update(inplace?) to stop, route, and vehicle objects; to allow developers to refresh realtime data without having to make new calls.

The inplace parameter should be false by default and return a new object to prevent developers from accidentally changing objects that are in use by other concurrent operations.

Reason

Prevent redundant calls to the base object and to reduce confusion for developers expecting the realtime data to update everytime they make a call.

@Katsute Katsute added feature request mta-subway Subway related issues and features mta-bus Bus related issues and features mta-mnr Metro North Railroad related issues and features mta-lirr Long Island Railroad related issues and features labels Feb 28, 2022
@Katsute
Copy link
Member Author

Katsute commented Mar 8, 2022

Possibly add internal interface method init() to initialize and update objects, rather than seting the value directly on the variable and instantiation.

This could open the door to using protected/package-private initializers.

ex: instead of copying and pasting the static route initialization across all route implementations, use a single initializer RouteSchema#init(Route route) and set the values using route.??? = ???

private final String routeID = id;
private final String routeShortName = row.get(csv.getHeaderIndex("route_short_name"));
private final String routeLongName = row.get(csv.getHeaderIndex("route_long_name"));
private final String routeDesc = row.get(csv.getHeaderIndex("route_desc"));
private final String routeColor = row.get(csv.getHeaderIndex("route_color"));
private final String routeTextColor = row.get(csv.getHeaderIndex("route_text_color"));

vs

protected final String routeID = id;
  
protected final String routeShortName; 
protected final String routeLongName; 
protected final String routeDesc; 
  
protected final String routeColor; 
protected final String routeTextColor;
protected final void init(Route route){
   route.routeShortName = row.get(csv.getHeaderIndex("route_short_name"));
   ...
}

@Katsute
Copy link
Member Author

Katsute commented Mar 15, 2022

Only realtime data should be updated, static data should be final. Any arrays should also be regenerated and reassigned, don't update existing arrays.

@Katsute
Copy link
Member Author

Katsute commented Mar 15, 2022

First comment method can't be used, protected variables in abstract is not allowed.

Instead move update method to the alerts and vehicles array method. Have optional param update? to determine if class should regenerated arrays, rather than using existing; again use new array, do not update old one.

@Katsute Katsute self-assigned this Mar 15, 2022
@Katsute
Copy link
Member Author

Katsute commented Mar 15, 2022

@sinon-bot branch refresh

@ghost
Copy link

ghost commented Mar 15, 2022

New branch created refresh@efe23fe

This branch was created by @Katsute.

@Katsute Katsute linked a pull request Mar 15, 2022 that will close this issue
16 tasks
@Katsute Katsute added this to the 1.1.0 milestone Mar 19, 2022
@ghost ghost locked and limited conversation to collaborators Mar 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature request mta-bus Bus related issues and features mta-lirr Long Island Railroad related issues and features mta-mnr Metro North Railroad related issues and features mta-subway Subway related issues and features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant