Upgrade to Pro — share decks privately, control downloads, hide ads and more …

20130126_Titanium新年会LT

100f944949861b8c4be7ba349820fb7a?s=47 Keigo AOKI
January 26, 2013

 20130126_Titanium新年会LT

Titanium新年会で披露したLTのスライドです。内容はAlloyの濃い目の小ネタの紹介。

※発表したスライドには会員限定コンテンツの個人情報が含まれていたので、一部をモザイク処理しています。

100f944949861b8c4be7ba349820fb7a?s=128

Keigo AOKI

January 26, 2013
Tweet

More Decks by Keigo AOKI

Other Decks in Programming

Transcript

  1. None
  2. None
  3. • • • • •

  4. None
  5. None
  6. None
  7. None
  8. None
  9. <Alloy> <Collection src="book" /> <Window class="container"> <TableView dataCollection="book" dataTransform="transformFunction"> <TableViewRow

    title="{title}" /> </TableView> </Window> </Alloy> $.index.open(); function transformFunction(model) { var transform = model.toJSON(); transform.title = '[' + transform.title + '] by ' + transform.author; return transform; } Alloy.Collections.book.fetch(); sample.xml • • sample.js
  10. <Alloy> <Model src="session" /> <Window class="container"> <View> <Label id="userName" text="{session.userName}"

    /> </View> </Window> </Alloy> $.index.open(); Alloy.Models.session.fetch(); sample.xml • • sample.js
  11. None
  12. None
  13. None
  14. None
  15. None
  16. // 略 var __alloyId70 = function() { $.__alloyId66.text = _.isFunction(Alloy.Models.session.transform)

    ? Alloy.Models.session.transform().userName : Alloy.Models.session.get("userName"); }; Alloy.Models.session.on("fetch change destroy", __alloyId70); // 略 sample.js • • •
  17. extendModel: function(Model) { _.extend(Model.prototype, { transform: function() { var model

    = this.toJSON(); if (_.isEmpty(model.userName)) { model.userName = 'Guest'; } return model; } }); // end extend return Model; }, session.js • • • •
  18. • • •

  19. • • •

  20. None