{"_id":"56f2d48da0de870e003b6cac","version":{"_id":"5668fab608f90021008e8832","__v":19,"project":"5668fab608f90021008e882f","createdAt":"2015-12-10T04:08:22.769Z","releaseDate":"2015-12-10T04:08:22.769Z","categories":["5668fab708f90021008e8833","569740f124490c3700170a64","569742b58560a60d00e2c25d","569742bd0b09a41900b2446c","569742cd69393517000c82b3","569742f459a6692d003fad8f","569743020b09a41900b2446d","5697430b69393517000c82b5","56a17776470ae00d00c30642","56a2c48a831e2a0d0069b1ad","56b535757bccae0d00e9a1cd","56e1ff6aa49fdc0e005746b5","57e1c88115bf6522002a5e4e","57fa65275ba65a17008b988f","57fbeea34002550e004c032e","58474584889b6c2d00fb86e9","58475dcc64157f0f002f1907","587e7b5158666c2700965d4e","58a349fc30852819007ba083"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.18.0","version":"1.18"},"parentDoc":null,"project":"5668fab608f90021008e882f","user":"5668fa9755e4b32100935d41","__v":7,"category":{"_id":"569743020b09a41900b2446d","__v":3,"pages":["56975be30b09a41900b24494","56a15cfd470ae00d00c3061f","56e356004dc30f0e0051b3ed"],"project":"5668fab608f90021008e882f","version":"5668fab608f90021008e8832","sync":{"url":"","isSync":false},"reference":true,"createdAt":"2016-01-14T06:41:06.893Z","from_sync":false,"order":2,"slug":"javascript-sdk","title":"JavaScript SDK"},"githubsync":"","updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-03-23T17:38:21.506Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":true,"order":8,"body":"`$p(\"register\"): (Object) -> Boolean`\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Technical documentation\",\n  \"body\": \"This page includes technical documentation around the register function, used as part of the code to render LiftIgniter recommendations. For broader context around rendering, see our documentation on [Rendering Widgets](doc:rendering-widgets).\"\n}\n[/block]\nRegister function prepares recommendation query to LiftIgniter's model server. You can set multiple registers before running $p(\"fetch\"). Every time the register function is invoked, then our SDK will queue that request, and execute it once $p(\"fetch\") is invoked.\n\nRegister calls are differentiated by the `opts` object passed into options. So number of model queries being made will be equal to number of registers with different kind of `opts` parameter.\n\nThe output of the register call is true if the register was successful, and false if not.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// Requests for articles that were published within last 24 hours\\n$p(\\\"register\\\",{\\n\\tmax:5,\\n  widget: \\\"new_news\\\",\\n  opts: {maxAgeInSeconds: 60*60*24},\\n  callback: function(resp){\\n    console.log(resp)\\n  }\\n})\\n\\n// Requests for articles that's marked as news.\\n$p(\\\"register\\\",{\\n\\tmax:5,\\n  widget: \\\"news_rec\\\",\\n  opts: {channel: \\\"news\\\"},\\n  callback: function(resp){\\n    console.log(resp)\\n  }\\n})\\n\\n// Calling fetch once executes both registers.\\n// Results in two different kinds of recommendations.\\n$p(\\\"fetch\\\")\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"pregister","type":"fn","title":"$p(\"register\")"}
`$p("register"): (Object) -> Boolean` [block:callout] { "type": "info", "title": "Technical documentation", "body": "This page includes technical documentation around the register function, used as part of the code to render LiftIgniter recommendations. For broader context around rendering, see our documentation on [Rendering Widgets](doc:rendering-widgets)." } [/block] Register function prepares recommendation query to LiftIgniter's model server. You can set multiple registers before running $p("fetch"). Every time the register function is invoked, then our SDK will queue that request, and execute it once $p("fetch") is invoked. Register calls are differentiated by the `opts` object passed into options. So number of model queries being made will be equal to number of registers with different kind of `opts` parameter. The output of the register call is true if the register was successful, and false if not. [block:code] { "codes": [ { "code": "// Requests for articles that were published within last 24 hours\n$p(\"register\",{\n\tmax:5,\n widget: \"new_news\",\n opts: {maxAgeInSeconds: 60*60*24},\n callback: function(resp){\n console.log(resp)\n }\n})\n\n// Requests for articles that's marked as news.\n$p(\"register\",{\n\tmax:5,\n widget: \"news_rec\",\n opts: {channel: \"news\"},\n callback: function(resp){\n console.log(resp)\n }\n})\n\n// Calling fetch once executes both registers.\n// Results in two different kinds of recommendations.\n$p(\"fetch\")", "language": "javascript" } ] } [/block]