Posts

Showing posts from August, 2017

My #PolymerSummit 2017, day 2 takeaways

Image
During day 1 of the Polymer Summit , we learnt about the Polymer 3 shift to JavaScript Modules and the NPM package manager. We were introduced to the template property getter, which returns your component's Shadow DOM, rather than using a template tag: static get template() {   return `<div>My component contents,  with tags and everything! ${interpolated_value_here}</div> `; } On day 2, we got introduced to the lit-html template library which gives us the html template tag and a render function: const helloTemplate = ( name ) => html ` < div >Hello ${ name } !</ div > ` ; // renders <div>Hello Steve!</div> to the document body render ( helloTemplate ( ' Steve ' ), document . body ); // updates to <div>Hello Kevin!</div>, but only updates the ${name} part render ( helloTemplate ( ' Kevin ' ), document . body ); This library can also be used with a component system that renders your component

My #PolymerSummit 2017, day 1 takeaways

Good news everyone! The live stream from day 1 is available on YouTube ! In version 3, Polymer will transition from using Bower as a package manager, to using NPM. This to "reduce the weirdness" within in the Project, i.e. align it to the rest of the world, as the Bower project is being deprecated. Pointing out that Bower still was a technically sound choice, the speaker stressed that there was no immediate hurry to get off it right now  (more on that later). Version 3 will also change module loader from HTML Imports to JS Modules. This is due to the fact that HTML Imports have failed to take off in the community of browser vendors. With these two changes, Polymer will work better alongside UI Frameworks and will be easier to adopt, since it uses technology you might already know. Given these two major changes, the Polymer team has decided to chill on the API changes. As such, they are also working on a converter tool that will take your Polymer 2 project and rewrite it

Getting started with Polymer 2 on Windows and the Shadow DOM

Image
*update* The very first code lab during the summit explained this so much better than I! Check it out here ! I'm writing this super-excitedly on my way to Polymer Summit in Copenhagen! In order to get ready for tomorrow's teachings, I figured I'd get my machine ready to Polymer. Following the getting started guide at https://www.polymer-project.org/2.0/start/install-2-0 on a fairly fresh install, I ran into the following issues: 1. Bower wasn't installed ( npm install -g bower ) 2. Git wasn't installed ( https://git-scm.com/download/win ) (I already had node.js installed ) After I'd installed git for Windows , I opted to just run the rest of the tutorial from the git bash. It worked a lot better! (I chose to overwrite the previously generated files when prompted, since it had failed). Reading https://www.polymer-project.org/2.0/docs/devguide/shadow-dom , something that struck me that I hadn't realized earlier, was that you can style Polymer

Json.NET is not deserializing my pretty object!

This stumped me for a while, so I figured I'd share. I had this type     public struct ChangeNameEvent : IEvent     {         public string Name { get; private set; }         public uint Id { get; private set; }         public ChangeNameEvent(string name, uint id)         {             Name = name;             Id = id;         }     } ... and this Unit Test ...         [TestMethod]         public void TestMethod4()         {             var serializationSettings = new JsonSerializerSettings             {                 TypeNameHandling = TypeNameHandling.All             };             const string serializedObject = "{\"$type\":\"Domain.ChangeNameEvent, ProperDomani\",\"Name\":\"Admin\",\"Id\":42}";             var evt = (IEvent)JsonConvert.DeserializeObject(                 serializedObject, serializationSettings);             Assert.AreEqual(42u, evt.Id);             Assert.IsInstanceOfTy