Bestand wählen
Merken

Array Computed Properties

Zitierlink des Filmsegments
Embed Code

Automatisierte Medienanalyse

Beta
Erkannte Entitäten
Sprachtranskript
a long language I don't think and the in a at
the time that
I so when did health I'm here to give a talk about so a rate properties start with a quick recap what is a computer property that this handy definition from the Member death website that defines them in terms of functions there's a really simple way of thinking that
at 80 compute property it's just a dynamic value but it's computed from some set of dependent properties an important thing to mind is that when a dependent properties change to compute property is completely invalid there is a very simple example have person name for the computer property Louvain depends on named it's just the same thing in all caps important point here is that when we change the dependent property set name as there is no sense of partial recompetition so
these 2 properties so this makes sense for set single values but what we do about race so you might just try to do the very same thing here is our Sin example where we have a computer property that is returned an array of names that depends on an array of this will actually work switch if we need take the array nothing gets changed in this case we add Berwick to our list of of people and a doesn't show and the reason is that when we depend on names the computer property will be completely invalidated when the dependent property is replaced the knowledge natives and not when an item in the dependent array is replaced or when items is added the array or OpenShift from your a or whatever there's a simple solution there's a virtual computer property bracketed bracket so if we take almost the same example but now we depend on names but made up record brackets protest works that we can you take dependent we and Berwick and now we have this nice list of people so that's might not accept their tuitions was approach about 1 this doesn't handle dependencies on a rainy on properties of objects and also a lot of the work is already being we done so we have to we went to cycle through the entire array of more Eugene Vendome villas even though they haven't changed all that we just added 1 item to a dependent to have deal with all pairs how we do the 1st problem is how we can use that at each a property names so so in this example again 1st will have a little helper which is just gonna Let's recreate the example but with properties behind objects rather than just simple strings now we have a ray of the same people and so depending on people that Brekken bracket will depend on people at each name and now I will recompute rain not only when it gets mutated by having editions of war by swapping out items and but also if any of its existing items have their name property changes in this case we we swapped out Eugene for over and that'll get reflected in the computer but again we're going through the entire related to that so this takes care of that 1st problem but not that a problem it's still
the case the most of the work is being done so if you if you wind up mutating and items or push and items on the stack and need to recompute the computer every time you're doing in school and work this is the entire points of a rate engine break computers deal with this case where we do a small amount of work to a dependent and we minimize the amount of work we have to do to updates computer properties so let's take this same example again only this time we use computer which uses an array computed and this works the same function as before that we we get a new value when we add when you take array by adding islands and also we observe properties but now we're only modifying we're only running the function that we pass ever at twice once for each annotation rather than looking over the entire we compare this to the code so what we can so in the above you see that the old code down the code using an educated man you can see the difference is like supplying the whole entire loop versus just supplying the body and this is the reason why embers able to only do partially competitions because we have the body of a loop of the only like couple items of change which is we apply that body rather than looping over the entire so compute is a common of cases a the performance and there are many other macros probably the ones the most used on or map that filter and sort but there's a few others
however you need to build a right you're up and the API exists for unity that so a high you can write your own a rating injured properties recomputed macros so his around in our look at the API so this is how you would say retrieve 1 functions use about recomputed and it looks a lot like a normal computer property you create using ever computed you got a list of you you have not reduced the penalties on your last argument instead being a function that determines how about dynamic values computed some of the few things it's got to required functions a 1 is added item and remove that what to do about and added with United's removed and optionally also function for initializing theory computers there a signature for initialize just have the initial value the array of some men information change manner and that information for the instance so the Rays just initial value it's just entering change metaphor initialize contains not too much has a reference to the computer property and has the name of the property on the object so in the previous example that would be allowed names instance that is used internally at all this is just a scratch pad have for you to do whatever side work site calculations you need to do to maintain your rate computed so as for instance if you're implementing uniqueness how you would want to keep track of the counts of individual objects so that you know when the last 1 had been removed from the dependencies added item looks similar to the main difference in the signatures you can see it also includes the items that and the properties are much the same way except as I said before you you also have the item is just an added and change that includes a couple more things that includes the array change which matters if you depend on multiple arrays and the index of item within that right so this is useful if you are a computer needs to be order-preserving so as an example were computed map is order-preserving I've ever computed sort is obvious enough instance measures the same scratch pad of pattern to initialize obviously it's just shared between all of these complex remove that looks almost exactly the same as Adleman the only difference is that it's called a different time of remove item you might imagine is called when is removed from a dependent right so when that is added to the array so it's not like prying removing atoms but we didn't cover modifying items at all so here is an example much like we had before using a recomputed where we depend on some upstream array and a property of each item so why does this work and the answer is that all modifications being in a in a rate computers are treated as a removal and the subsequent react so this is why were able to gets property modifications to work even though we only pass callbacks for adding and removing it so 1 difference when an item is removed as a result of any property change is the change may also includes previous factors which is just a plain old jobs with objects that contains a its key down the properties that change and the value of the old I usually when you just do a set that this is this is gonna have exactly 1 key-value pair and we all value is useful when you it can help you do removal better so the the simplest example is in sort if you have the old value during removal you can remove something efficiently and log I just as with the new value in addition you can remove you can add the animal OK so here is the entire implementation of can kidnap straight from the source-code conceded it it's fairly straightforward it is mostly defined in terms of these 2 call into the had item and remove and and appreciate sort most the real work is being done in IR rate computed all of the observer management's it's all done of strings so that's all you need to know to be able to do simple array computers array computer properties but as you do some these you rent a certain issues were go over some some more common ones that 1 is what happened with honorary dependencies have working with IDE controllers and also proxies generally and how makes the 1 at a time with complete invalidations so 1st things 1st you might think what does this do what happens if I have a computer that has a dependency that's array and depends it's not when I'm not worried Penzias changed the array Q properties completely invalid if know this isn't surprising it's because an array computer property is just a particular kind of computer properties so it still has all the same semantics that regular computer properties have so if you you can have non array dependencies you just won't have the array observers initialize won't have this 1 at a time semantics you'll just have a total invalidation as if it were any other kind
of computer property that's so working with iron controllers you might have something like this so the the most common time working with I controllers is the array controllers sofas you I don't remember us with the array controller you can specify and controller and then when you retrieve items from the array we treat it like a red that be wrapped in specified controller so in this case if we do have people in troller object at 3 we won't get the person we won't get the in the record from the model property will get up person controller the proxies notable how would you like what's the What's the rights property put here so you can certainly just depend on the model property and that will work but they won't get you or a your item controllers you just get the roll items which can be fined up less your item controller has properties that you're computer depends on conceptually this is what you want you want property that just returns the array controller itself and this actually this concluding works you can do this and it's totally reasonable and this will give you exactly what you what what'll happen is array computable Tate will grab the self property as the array handle treated like array and that's will be getting the optic that's and that's how well 1 of the proxy however because this is such a common cases usually when you have I controllers and those are the things you want to deal with rather than the raw items there's a nice so sure that you can use a which is at this because conceptually that's the thing that you want to specify USA it's the app it's the array controller itself that is the source of light is the C. P. equivalents of the junta this keyword right so the last thing the more advanced issues is mixing 1 at a time and complete invalidation semantics so you may have multiple re dependencies some of which you will want and 4 and some of which you want total knowledge for us so the com examples are different kinds of filtering where you'll have so for instance a list of flags like I include these tags don't include these tags and a list of items so when items added removed you want have semantics with flight added or removed then you just need to restart itself the has had reduced the thing to remember is that although the managing the array observers or computer properties just like other computer properties so we can do exactly what we did diverse 1st presentation industries Brackney brackets and what this will do when we say that this array computer depends on upstream but depends on flags of rapid bracket it mean that flags when items added or removed will completely invalidate the property and upstream array will use the added item and remove and collects out 1 thing to keep in mind as a sort of rule of thumb is that you always want least 1 dependent key waiver-wire defense and x i if you don't have as you just using a regular computer property and the reason I say only sort of rule of thumb is that it's it's much more strict rules from you absolutely want at least 1 depending key with what advanced methods so as you just use the the ready to be so you might notice that array computer properties are a little bit like a reduced form of functional programming of point of view at where the produce only happens to be see you may wonder well OK the upstream has to be an array of wasn't much sense has to be some kind of real like thing but can we have 1 a time semantics where the computed value is not a unfortunately answer is no all the candle lame rhetorical question of accidents and of course we can and have the ends in certain British computed so here is how you do reduce computed and you'll notice it looks almost exactly like in array computed the chief difference is that is that the war all the the past the end also includes an initial value so this be a function that returns as you might guess the initial value for simple values it's fine to just have the value itself so for numbers strings and so on you don't need at a function although it's just a short so here's 1 last example where we look through produce computed we look through some of the solutions theory how you could do a unique for instance someone wants us at semantics so our initial values is going to be a set and but we're going to have an instance manner that just to keep track of the accounts of items that we talked about earlier so when items added we just count how many times it seems odd and it is the 1st time we had set when atoms removed we reduce the number of times we've seen as an effective for down a 0 we remove set 5 depending on the size of such expects and how you want to measure in science man you would also potentially delete the from from that scratch that at this time as well That's it thank you
the other hand the and things and the and the the living in a kind of and a and the
Videokonferenz
XML
Formale Sprache
Kombinatorische Gruppentheorie
Lineares Funktional
Web Site
Punkt
Menge
Diskretes System
Gasströmung
Partielle Differentiation
Computer
Bitrate
Term
Kugelkappe
Objekt <Kategorie>
Subtraktion
Punkt
Virtualisierung
Mathematisierung
Computer
Computerunterstütztes Verfahren
Code
Eins
Loop
Datensatz
Poisson-Klammer
PERM <Computer>
Zustand
Kontrollstruktur
Metropolitan area network
Sinusfunktion
Lineares Funktional
Spieltheorie
Mailing-Liste
Bitrate
Quick-Sort
Objekt <Kategorie>
Funktion <Mathematik>
Loop
Dreiecksfreier Graph
Makrobefehl
Makrobefehl
Zeichenkette
Resultante
Bit
Konfiguration <Informatik>
Punkt
Regulärer Graph
Luenberger-Beobachter
Computer
Computerunterstütztes Verfahren
Extrempunkt
Zählen
Technische Optik
Formale Semantik
Eins
Poisson-Klammer
Dedekind-Schnitt
Dämpfung
Regulärer Graph
Fahne <Mathematik>
Prozess <Informatik>
Gamecontroller
Fahne <Mathematik>
Mustersprache
Gleitendes Mittel
Metropolitan area network
App <Programm>
Lineares Funktional
Addition
Parametersystem
Sichtenkonzept
Vervollständigung <Mathematik>
Systemaufruf
Ausnahmebehandlung
Quellcode
Bitrate
Rechnen
Elektronische Unterschrift
Teilbarkeit
Funktion <Mathematik>
Menge
Einheit <Mathematik>
Automatische Indexierung
Datenverarbeitungssystem
Rechter Winkel
Information
Eindeutigkeit
Makrobefehl
Schlüsselverwaltung
Instantiierung
Zeichenkette
Objekt <Kategorie>
Proxy Server
Formale Semantik
Subtraktion
Web Site
Thumbnail
Mathematisierung
Zahlenbereich
Implementierung
Anfangswertproblem
Ordinalzahl
Äquivalenzklasse
Kombinatorische Gruppentheorie
Term
Physikalische Theorie
Überlagerung <Mathematik>
Multiplikation
Datensatz
Informationsmodellierung
Bildschirmmaske
Weg <Topologie>
Reelle Zahl
PERM <Computer>
COM
Luenberger-Beobachter
Graphiktablett
Eindeutigkeit
Indexberechnung
Schlussregel
Mailing-Liste
Quick-Sort
Objekt <Kategorie>
Mapping <Computergraphik>
Makrobefehl
Gamecontroller
Normalvektor
Funktionale Programmiersprache
Videokonferenz
Offene Menge
Hill-Differentialgleichung

Metadaten

Formale Metadaten

Titel Array Computed Properties
Serientitel EmberConf 2014
Autor Hamilton, David
Lizenz CC-Namensnennung - Weitergabe unter gleichen Bedingungen 3.0 Unported:
Sie dürfen das Werk bzw. den Inhalt zu jedem legalen und nicht-kommerziellen Zweck nutzen, verändern und in unveränderter oder veränderter Form vervielfältigen, verbreiten und öffentlich zugänglich machen, sofern Sie den Namen des Autors/Rechteinhabers in der von ihm festgelegten Weise nennen und das Werk bzw. diesen Inhalt auch in veränderter Form nur unter den Bedingungen dieser Lizenz weitergeben.
DOI 10.5446/35005
Herausgeber Confreaks, LLC
Erscheinungsjahr 2014
Sprache Englisch

Inhaltliche Metadaten

Fachgebiet Informatik
Abstract Computed properties are an important feature for any ember.js developer to master. This talk offers an overview of a particular subset of computed properties: array computed properties, which allow for partial recomputation. This is the feature that saves, for instance, `Ember.computed.filterBy` from having to completely recompute the filtered array when an item is added to its dependent array.

Ähnliche Filme

Loading...
Feedback