mirror of
https://github.com/discourse/discourse.git
synced 2025-03-31 14:28:11 +08:00
REFACTOR: Remove discourse/lib/throttle
This commit is contained in:
parent
4ddb69e9c6
commit
e8dae447bd
@ -26,7 +26,6 @@
|
||||
//= require ./discourse/lib/lock-on
|
||||
//= require ./discourse/lib/url
|
||||
//= require ./discourse/lib/debounce
|
||||
//= require ./discourse/lib/throttle
|
||||
//= require ./discourse/lib/quote
|
||||
//= require ./discourse/lib/key-value-store
|
||||
//= require ./discourse/lib/computed
|
||||
|
@ -1,19 +0,0 @@
|
||||
import { throttle } from "@ember/runloop";
|
||||
/**
|
||||
Throttle a Javascript function. This means if it's called many times in a time limit it
|
||||
should only be executed one time at most during this time limit
|
||||
Original function will be called with the context and arguments from the last call made.
|
||||
**/
|
||||
export default function(func, spacing, immediate) {
|
||||
let self, args;
|
||||
const later = function() {
|
||||
func.apply(self, args);
|
||||
};
|
||||
|
||||
return function() {
|
||||
self = this;
|
||||
args = arguments;
|
||||
|
||||
throttle(null, later, spacing, immediate);
|
||||
};
|
||||
}
|
@ -16,7 +16,7 @@ import {
|
||||
} from "discourse-common/utils/decorators";
|
||||
import { escapeExpression, tinyAvatar } from "discourse/lib/utilities";
|
||||
import { propertyNotEqual } from "discourse/lib/computed";
|
||||
import throttle from "discourse/lib/throttle";
|
||||
import { throttle } from "@ember/runloop";
|
||||
import { Promise } from "rsvp";
|
||||
import { set } from "@ember/object";
|
||||
|
||||
@ -226,15 +226,18 @@ const Composer = RestModel.extend({
|
||||
return this.set("metaData", EmberObject.create());
|
||||
},
|
||||
|
||||
// view detected user is typing
|
||||
typing: throttle(
|
||||
function() {
|
||||
const typingTime = this.typingTime || 0;
|
||||
this.set("typingTime", typingTime + 100);
|
||||
},
|
||||
100,
|
||||
false
|
||||
),
|
||||
// called whenever the user types to update the typing time
|
||||
typing() {
|
||||
throttle(
|
||||
this,
|
||||
function() {
|
||||
const typingTime = this.typingTime || 0;
|
||||
this.set("typingTime", typingTime + 100);
|
||||
},
|
||||
100,
|
||||
false
|
||||
);
|
||||
},
|
||||
|
||||
editingFirstPost: and("editingPost", "post.firstPost"),
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user