« first day (1848 days earlier)      last day (3098 days later) » 

11:00 PM
1) Lots of complicated and bug-ridden string manipulation & math
2) Library
 
@AminRoosta You have the UTC counterparts of the date part grabbing functions
So date.getUTCHours() and so forth
!!tell AminRoosta mdn Date
 
@AminRoosta Date
 
@Zirak again life saver :) thank you very much.
@SomeKittens thank you too.
 
@Zirak lol, I don't even remember that
 
11:19 PM
they should just put moment in ES7
 
Trying to wrap my head around making calls to external APIs in my Angular application
I heard this is best done in a service or factory to avoid cramming controllers with this kind of thing
Can anyone comment on this?
 
That's correct
A controller shouldn't care about where the data is coming from.
 
great
so suppose I am making calls to an api
that returns json that i need to parse
currently as it stands I have my calls using $http and json parsers in living in one large factory
i want to break this down but not sure how to best go about this
 
11:36 PM
Break up the factories by what they're asking for
one for user data, another for posts, etc, etc
 
interesting
what about json parsers?
 
Angular isn't doing that for you?
if you respond with content-type: application/json it should be parsed
 
yeah but I have to slice through that since it doesn't always come in the format that I want
API returns json with tons of nested objects
make sense?
 
oh, yeah
I had to do something like that earlier today
 
@phenomnomnominal what? link?
 
11:38 PM
$http.get(url)
.then(function (res) {
  return res.data.filter(myFilterFunc);
});
etc, etc
 
right so where should my filter function live?
same place where the corresponding $http call lives?
 
Unless it's your own API, in which case fix it serverside
 
In the service
(and yeah, fix it serverside if you can)
 
fix it serverside?
most of the calls are to external APIs like Spotify and Songkick
but I am curious what you mean by fix it serverside
 
In that case, you can't really fix it serverside.
 
11:41 PM
So you mean if I was making API calls to my backend to retrieve data from my database?
 
yeah, in that case you've got control, so return the data you need
 
right
got it
 
I've seen people go to great lengths to clean up data in the browser that they could have cleaned up in their server so I was just checking. If it's an external API you don't have much choice unless you want to proxy it
 
What if I split my services and factories by their API
so like SpotifyFactory.js and SongKickFactory.js
code test
 
@theamateurdataanalyst Yup, just like that
 
11:46 PM
function MyFactory($http){ myFactory = {} myFactory.funcOne = function(){}; myFactory.funcTwo = (){var two = myFactory.funcOne() return two;}}
gah that looks sloppy
but last question about a pattern that I have been dealing with that I think may be a bad practice
and thats using a factory function within another factory function from the same factory
bad idea?
ah I forget to return myFactory in my code snippet so pardon that
 
not bad generally
you can have stuff that's too deeply nested
 
I've seen factories that were essentially returning only just the call to another factory.
useless piping
cat file | xargs echo
 
Awesome @SomeKittens thanks for your help
its hard to find help with it comes to more 'subjective' questions regarding Angular
I feel like this stuff can be much more opinion based and its a product of a developers experience with a framework or technology
Any tips on how to avoid anti-patterns?
Or is this just something that you learn from experience?
 
11:54 PM
sweet library
 
@theamateurdataanalyst Find devs with experience, ask lots of questions
 
@phenomnomnominal i meant about the "adding to es7" part
 
I want that API but on the native Date
 
ohh, "should". I missed that word.
 
but maybe a Time object to prevent fucking the old stuff
 
11:58 PM
i find momentjs useful, but i don't like it's API
I'd prefer non-mutable dates.
 
a native Time object would be nice
for adding etc
 

« first day (1848 days earlier)      last day (3098 days later) »