當前位置: 首頁>>代碼示例>>Golang>>正文


Golang livereload.Reloader類代碼示例

本文整理匯總了Golang中github.com/cortesi/devd/livereload.Reloader的典型用法代碼示例。如果您正苦於以下問題:Golang Reloader類的具體用法?Golang Reloader怎麽用?Golang Reloader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Reloader類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: WatchPaths

// WatchPaths watches a set of paths, and broadcasts changes through reloader.
func WatchPaths(paths, excludePatterns []string, reloader livereload.Reloader, log termlog.Logger) error {
	ch := make(chan []string, 1)
	for _, path := range paths {
		absPath, err := filepath.Abs(path)
		if err != nil {
			return err
		}
		if absPath[len(absPath)-1] != filepath.Separator {
			absPath += string(filepath.Separator)
		}

		pathchan := make(chan []string, 1)
		err = watch.Watch(path, batchTime, pathchan)
		if err != nil {
			return err
		}
		go func() {
			for files := range pathchan {
				files = filterFiles(absPath, files, excludePatterns, log)
				if len(files) > 0 {
					ch <- files
				}
			}
		}()
	}
	go reloader.Watch(ch)
	return nil
}
開發者ID:wzugang,項目名稱:devd,代碼行數:29,代碼來源:watch.go

示例2: WatchRoutes

// WatchRoutes watches the route collection, and broadcasts changes through reloader.
func WatchRoutes(routes RouteCollection, reloader livereload.Reloader, excludePatterns []string, log termlog.Logger) error {
	c := make(chan []string, 1)
	for i := range routes {
		err := routes[i].Watch(c, excludePatterns, log)
		if err != nil {
			return err
		}
	}
	go reloader.Watch(c)
	return nil
}
開發者ID:wzugang,項目名稱:devd,代碼行數:12,代碼來源:watch.go

示例3: WatchPaths

// WatchPaths watches a set of paths, and broadcasts changes through reloader.
func WatchPaths(paths, excludePatterns []string, reloader livereload.Reloader, log termlog.Logger) error {
	ch := make(chan []string, 1)
	for _, path := range paths {
		modchan := make(chan modd.Mod, 1)
		err := modd.Watch([]string{path}, excludePatterns, batchTime, modchan)
		if err != nil {
			return err
		}
		go func() {
			for mod := range modchan {
				ch <- mod.All()
			}
		}()
	}
	go reloader.Watch(ch)
	return nil
}
開發者ID:Ezmyrelda,項目名稱:devd,代碼行數:18,代碼來源:watch.go

示例4: WatchPaths

// WatchPaths watches a set of paths, and broadcasts changes through reloader.
func WatchPaths(paths, excludePatterns []string, reloader livereload.Reloader, log termlog.Logger) error {
	ch := make(chan []string, 1)
	for _, path := range paths {
		modchan := make(chan modd.Mod, 1)
		err := modd.Watch(path, batchTime, modchan)
		if err != nil {
			return err
		}
		go func() {
			for mod := range modchan {
				files := filterFiles(mod.All(), excludePatterns, log)
				if len(files) > 0 {
					ch <- files
				}
			}
		}()
	}
	go reloader.Watch(ch)
	return nil
}
開發者ID:roryokane,項目名稱:devd,代碼行數:21,代碼來源:watch.go

示例5: WatchPaths

// WatchPaths watches a set of paths, and broadcasts changes through reloader.
func WatchPaths(paths, excludePatterns []string, reloader livereload.Reloader, log termlog.Logger) error {
	ch := make(chan []string, 1)
	for _, path := range paths {
		modchan := make(chan *moddwatch.Mod, 1)
		_, err := moddwatch.Watch([]string{path}, batchTime, modchan)
		if err != nil {
			return err
		}
		go func() {
			for mod := range modchan {
				filteredMod, err := mod.Filter([]string{"**/*"}, excludePatterns)
				if err != nil {
					log.Shout("Error filtering watches: %s", err)
				}
				if !filteredMod.Empty() {
					ch <- filteredMod.All()
				}
			}
		}()
	}
	go reloader.Watch(ch)
	return nil
}
開發者ID:cortesi,項目名稱:devd,代碼行數:24,代碼來源:watch.go


注:本文中的github.com/cortesi/devd/livereload.Reloader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。