Created
March 1, 2013 17:24
-
-
Save ovidiuch/5066247 to your computer and use it in GitHub Desktop.
Rethink Mozaic.newDataChannels
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
# Refactoring the way "newDataChannels" works, maybe with an alternative | |
# (temporary) "createChannels" method | |
# With current method: | |
[facebook_ad_accounts, | |
facebook_campaigns, | |
facebook_ads] = Utils.newDataChannels( | |
'/facebook-ad-accounts': {} | |
'/facebook-campaigns': {} | |
'/facebook-ads': {} | |
) | |
widget_params = | |
channels: | |
'/facebook-ad-accounts': facebook_ad_accounts | |
'/facebook-campaigns': facebook_campaigns | |
'/facebook-ads': facebook_ads | |
# UGH! :( | |
# With new method (when passing all channels): | |
widget_params = | |
channels: Utils.createChannels( | |
'/facebook-ad-accounts': {} | |
'/facebook-campaigns': {} | |
'/facebook-ads': {} | |
) | |
# With new method (when they need to be sent to other widgets as well): | |
channels = Utils.createChannels( | |
'/facebook-ad-accounts': {} | |
'/facebook-campaigns': {} | |
'/facebook-ads': {} | |
) | |
widget_params = | |
channels: channels | |
# With new method (when passing only a part of the channels): | |
channels = Utils.createChannels( | |
'/facebook-ad-accounts': {} | |
'/facebook-campaigns': {} | |
'/facebook-ads': {} | |
) | |
widget_params = | |
channels: _.pick(channels, '/facebook-campaigns', '/facebook-ads') | |
# How? We just need to return the created channels inside an object with | |
# corresponding keys instead of an array | |
# Yes @aismail, we could still send "fake names", and we get rid of a lot of | |
# headaches in 90% of cases: | |
channels = Utils.createChannels( | |
'/facebook-ad-accounts': {} | |
'/facebook-campaigns': {} | |
'/facebook-ads': {} | |
) | |
widget_params = | |
channels: | |
'/items': channels['/facebook-ads'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sounds cool as far as I'm concerned, also, the destructuring statement should still work via: