I'm creating a "scrambler" that takes in a text array and an image array, then computes the cross product as tweets. The function that I'm worried about looks like this:
combinations: (->
tweet_texts = @get('tweet_texts')
tweet_images = @get('tweet_images')
# return empty array unless we have texts
return Em.A([]) unless tweet_texts.length
# handle the case when we don't have images
unless tweet_images.length
combinations = tweet_texts.map (text) =>
TwitterPost.create
text : text
newtwork_user : @get('account.twitter_handle')
return Em.A(combinations)
# handle texts and images
combinations = tweet_images.map (image) =>
tweet_texts.map (text) =>
TwitterPost.create
text : text
image : image
network_user : @get('account.twitter_handle')
return Em.A([].concat(combinations...))
).property('tweet_texts.@each','tweet_images.@each')
My worry is that I'm creating a lot of models and I don't really understand Ember's garbage collection.
So, am I at risk of creating a memory leak here?
Thanks!