Git Product home page Git Product logo

react-angular-chimera's People

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

f-engstrom

react-angular-chimera's Issues

Don't use a watcher on model.value

Angular watchers are notoriously inefficient so should be avoided where possible. With that in mind, there are a few "special" Umbraco features you can make use of to achieve the same without the watcher overhead. A bare bones example would be

// here we declare a special method which will be called 
// whenever the value has changed from the server
$scope.model.onValueChanged = function (newVal, oldVal) {
  // Model value changed so update UI
  updateUi()
};

var unsubscribe = $scope.$on("formSubmitting", function () {
  // Write data back to the model.value
  $scope.model.value = ...
});

$scope.$on('$destroy', function () {
  unsubscribe();
});

Ultimately Umbraco checks for the special method onValueChanged and uses that to notify you if the model on the server changes, and the formSubmitting event gets fired when the form is about to send to the server, so you can hold off writing to $scope.model.value until the very last minute. The $destroy event handler just does some cleaning up to prevent memory leaks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.